JSONAPI is not finding nodes claiming "parameter was not converted"

Created on 1 February 2023, over 1 year ago
Updated 22 August 2023, 10 months ago

Problem/Motivation

I've got JSONAPI installed with JSONAPI UI in a fairly clean version of 10.0.3. The POST commands work as expected. The GET, though, is generating several different kinds of errors.

The basic URL: /jsonapi/node/article doesn't generate a list of articles but returns an error saying it was looking for a scalar. But when I do add a node UID, I get a slightly different kind of error saying, ""The \u0022entity\u0022 parameter was not converted for the path ." Perhaps I'm getting the UID and the UUIDs confused? Is there an easy way to figure out both of them for a given piece of content?

Thanks for any suggestions for what I might have misconfigured. (And if anyone knows a good way to figure out the full JSON format for all of the possible fields with a PUT, let me know. That's why I started experimenting with the GET.)

Here's the JSON for the first error:

{"jsonapi":{"version":"1.0","meta":{"links":{"self":{"href":"http:\/\/jsonapi.org\/format\/1.0\/"}}}},"errors":[{"title":"Internal Server Error","status":"500","detail":"Expected a scalar value as a 2nd argument to \u0022Symfony\\Component\\HttpFoundation\\InputBag::get()\u0022, \u0022array\u0022 given.","links":{"via":{"href":"http:\/\/XXX,COM/jsonapi\/node\/article"},"info":{"href":"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html#sec10.5.1"}},"source":{"file":"\/var\/www\/html\/AI1\/web\/core\/modules\/jsonapi\/src\/EventSubscriber\/DefaultExceptionSubscriber.php","line":49},"meta":{"exception":"InvalidArgumentException: Expected a scalar value as a 2nd argument to \u0022Symfony\\Component\\HttpFoundation\\InputBag::get()\u0022, \u0022array\u0022 given. in \/var\/www\/html\/AI1\/vendor\/symfony\/http-foundation\/InputBag.php:31\nStack trace:\n#0 \/var\/www\/html\/AI1\/web\/modules\/contrib\/jsonapi_extras\/modules\/jsonapi_defaults\/src\/Controller\/EntityResource.php(77): Symfony\\Component\\HttpFoundation\\InputBag-\u003Eget()\n#1 \/var\/www\/html\/AI1\/web\/core\/modules\/jsonapi\/src\/Controller\/EntityResource.php(412): Drupal\\jsonapi_defaults\\Controller\\EntityResource-\u003EgetJsonApiParams()\n#2 [internal function]: Drupal\\jsonapi\\Controller\\EntityResource-\u003EgetCollection()\n#3 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/EventSubscriber\/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()\n#4 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/Render\/Renderer.php(580): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber-\u003EDrupal\\Core\\EventSubscriber\\{closure}()\n#5 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/EventSubscriber\/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\\Core\\Render\\Renderer-\u003EexecuteInRenderContext()\n#6 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/EventSubscriber\/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber-\u003EwrapControllerExecutionInRenderContext()\n#7 \/var\/www\/html\/AI1\/vendor\/symfony\/http-kernel\/HttpKernel.php(163): Drupal\\Core\\EventSubscriber\\EarlyRenderingControllerWrapperSubscriber-\u003EDrupal\\Core\\EventSubscriber\\{closure}()\n#8 \/var\/www\/html\/AI1\/vendor\/symfony\/http-kernel\/HttpKernel.php(74): Symfony\\Component\\HttpKernel\\HttpKernel-\u003EhandleRaw()\n#9 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/Session.php(58): Symfony\\Component\\HttpKernel\\HttpKernel-\u003Ehandle()\n#10 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session-\u003Ehandle()\n#11 \/var\/www\/html\/AI1\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php(106): Drupal\\Core\\StackMiddleware\\KernelPreHandle-\u003Ehandle()\n#12 \/var\/www\/html\/AI1\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php(85): Drupal\\page_cache\\StackMiddleware\\PageCache-\u003Epass()\n#13 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/ReverseProxyMiddleware.php(48): Drupal\\page_cache\\StackMiddleware\\PageCache-\u003Ehandle()\n#14 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware-\u003Ehandle()\n#15 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/StackedHttpKernel.php(51): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware-\u003Ehandle()\n#16 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/DrupalKernel.php(681): Drupal\\Core\\StackMiddleware\\StackedHttpKernel-\u003Ehandle()\n#17 \/var\/www\/html\/AI1\/web\/index.php(19): Drupal\\Core\\DrupalKernel-\u003Ehandle()\n#18 {main}\n\nNext Symfony\\Component\\HttpKernel\\Exception\\HttpException: Expected a scalar value as a 2nd argument to \u0022Symfony\\Component\\HttpFoundation\\InputBag::get()\u0022, \u0022array\u0022 given. in \/var\/www\/html\/AI1\/web\/core\/modules\/jsonapi\/src\/EventSubscriber\/DefaultExceptionSubscriber.php:49\nStack trace:\n#0 [internal function]: Drupal\\jsonapi\\EventSubscriber\\DefaultExceptionSubscriber-\u003EonException()\n#1 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Component\/EventDispatcher\/ContainerAwareEventDispatcher.php(111): call_user_func()\n#2 \/var\/www\/html\/AI1\/vendor\/symfony\/http-kernel\/HttpKernel.php(221): Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher-\u003Edispatch()\n#3 \/var\/www\/html\/AI1\/vendor\/symfony\/http-kernel\/HttpKernel.php(89): Symfony\\Component\\HttpKernel\\HttpKernel-\u003EhandleThrowable()\n#4 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/Session.php(58): Symfony\\Component\\HttpKernel\\HttpKernel-\u003Ehandle()\n#5 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/KernelPreHandle.php(48): Drupal\\Core\\StackMiddleware\\Session-\u003Ehandle()\n#6 \/var\/www\/html\/AI1\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php(106): Drupal\\Core\\StackMiddleware\\KernelPreHandle-\u003Ehandle()\n#7 \/var\/www\/html\/AI1\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php(85): Drupal\\page_cache\\StackMiddleware\\PageCache-\u003Epass()\n#8 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/ReverseProxyMiddleware.php(48): Drupal\\page_cache\\StackMiddleware\\PageCache-\u003Ehandle()\n#9 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/NegotiationMiddleware.php(51): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware-\u003Ehandle()\n#10 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/StackedHttpKernel.php(51): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware-\u003Ehandle()\n#11 \/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/DrupalKernel.php(681): Drupal\\Core\\StackMiddleware\\StackedHttpKernel-\u003Ehandle()\n#12 \/var\/www\/html\/AI1\/web\/index.php(19): Drupal\\Core\\DrupalKernel-\u003Ehandle()\n#13 {main}","trace":[{"function":"onException","class":"Drupal\\jsonapi\\EventSubscriber\\DefaultExceptionSubscriber","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Component\/EventDispatcher\/ContainerAwareEventDispatcher.php","line":111,"function":"call_user_func"},{"file":"\/var\/www\/html\/AI1\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":221,"function":"dispatch","class":"Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/vendor\/symfony\/http-kernel\/HttpKernel.php","line":89,"function":"handleThrowable","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/Session.php","line":58,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/KernelPreHandle.php","line":48,"function":"handle","class":"Drupal\\Core\\StackMiddleware\\Session","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php","line":106,"function":"handle","class":"Drupal\\Core\\StackMiddleware\\KernelPreHandle","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/core\/modules\/page_cache\/src\/StackMiddleware\/PageCache.php","line":85,"function":"pass","class":"Drupal\\page_cache\\StackMiddleware\\PageCache","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/ReverseProxyMiddleware.php","line":48,"function":"handle","class":"Drupal\\page_cache\\StackMiddleware\\PageCache","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/NegotiationMiddleware.php","line":51,"function":"handle","class":"Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/StackMiddleware\/StackedHttpKernel.php","line":51,"function":"handle","class":"Drupal\\Core\\StackMiddleware\\NegotiationMiddleware","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/core\/lib\/Drupal\/Core\/DrupalKernel.php","line":681,"function":"handle","class":"Drupal\\Core\\StackMiddleware\\StackedHttpKernel","type":"-\u003E"},{"file":"\/var\/www\/html\/AI1\/web\/index.php","line":19,"function":"handle","class":"Drupal\\Core\\DrupalKernel","type":"-\u003E"}]}}]}

CURL example

Here's an example of what happens with CURL:

curl   --header 'Accept: application/vnd.api+json' \
> http://XXX.com/jsonapi/node/article
{"jsonapi":{"version":"1.0","meta":{"links":{"self":{"href":"http:\/\/jsonapi.org\/format\/1.0\/"}}}},"errors":[{"title":"Internal Server Error","status":"500","detail":"Expected a scalar value as a 2nd argument to \u0022Symfony\\Component\\HttpFoundation\\InputBag::get()\u0022, \u0022array\u0022 given.","links":{"via":{"href":"http:\/\/XXX.com\/jsonapi\/node\/article"},"info":{"href":"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html#sec10.5.1"}}}

And this is an example of looking for a particular article. The regular URL http://XXX.com/node/5 works fine.

$ curl   --header 'Accept: application/vnd.api+json'  http://XXX.com/jsonapi/node/article/5
{"jsonapi":{"version":"1.0","meta":{"links":{"self":{"href":"http:\/\/jsonapi.org\/format\/1.0\/"}}}},"errors":[{"title":"Not Found","status":"404","detail":"The \u0022entity\u0022 parameter was not converted for the path \u0022\/jsonapi\/node\/article\/{entity}\u0022 (route name: \u0022jsonapi.node--article.individual\u0022)","links":{"via":{"href":"http:\/\/XXX.com\/jsonapi\/node\/article\/5"},"info":{"href":"http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec10.html#sec10.4.5"}}}]}
🐛 Bug report
Status

Closed: works as designed

Version

10.0

Component
JSON API 

Last updated 2 days ago

Created by

🇺🇸United States bogdog400

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @bogdog400
  • 🇺🇸United States cilefen

    Can you please add to the issue summary the GET requests you are sending, preferably as CURL commands?

  • 🇺🇸United States bogdog400

    My GET commands aren't working, but the POSTs are.

    Above I noted that I was having trouble figuring out the JSON schema. This project helped me but only after I did a clean installation on 9.5.3. When I added fields to the article type in the 9.5.3, I could use the explorer to browse the GET response to guess at the right fields to put into the POST. As expected, these fields were unchanged in the version running on 10.0.3.

    https://www.drupal.org/project/jsonapi_explorer

    BTW, my biggest hassle was figuring out that cross origin scripting was blocking the JSON calls from the explorer. When I turned that off, I was able to get it to work.

  • Status changed to Closed: works as designed over 1 year ago
  • 🇺🇸United States camchandler98

    This is the output I got doing a GET request for all articles.
    Tested with a local drupal instance using Postman, Google Chrome, and cURL

    {"jsonapi":{"version":"1.0","meta":{"links":{"self":{"href":"http:\/\/jsonapi.org\/format\/1.0\/"}}},"parsed":true},"data":[{"type":"node--article","id":"a3250a45-5069-4790-96b0-279ddd3bcf73","links":{"self":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/a3250a45-5069-4790-96b0-279ddd3bcf73?resourceVersion=id%3A16"}},"drupal_internal__nid":5,"drupal_internal__vid":16,"langcode":"en","revision_timestamp":"2023-02-07T23:47:40+00:00","revision_log":null,"status":true,"title":"test 1","created":"2023-02-07T23:47:28+00:00","changed":"2023-02-07T23:47:40+00:00","promote":true,"sticky":false,"default_langcode":true,"revision_translation_affected":true,"path":{"alias":null,"pid":null,"langcode":"en"},"body":{"value":"\u003Cp\u003Etest 1\u003C\/p\u003E","format":"basic_html","processed":"\u003Cp\u003Etest 1\u003C\/p\u003E","summary":""},"comment":{"status":2,"cid":0,"last_comment_timestamp":1675813660,"last_comment_name":null,"last_comment_uid":1,"comment_count":0},"node_type":{"type":"node_type--node_type","id":"18971097-f4d9-44c8-a643-8546d9d09652","meta":{"drupal_internal__target_id":"article"}},"revision_uid":{"type":"user--user","id":"2983dfbb-a8bf-460f-85cc-ceac0d1e248a","meta":{"drupal_internal__target_id":1}},"uid":{"type":"user--user","id":"2983dfbb-a8bf-460f-85cc-ceac0d1e248a","meta":{"drupal_internal__target_id":1}},"field_image":{"data":null,"links":{"related":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/a3250a45-5069-4790-96b0-279ddd3bcf73\/field_image?resourceVersion=id%3A16"},"self":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/a3250a45-5069-4790-96b0-279ddd3bcf73\/relationships\/field_image?resourceVersion=id%3A16"}}},"field_tags":{"data":[],"links":{"related":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/a3250a45-5069-4790-96b0-279ddd3bcf73\/field_tags?resourceVersion=id%3A16"},"self":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/a3250a45-5069-4790-96b0-279ddd3bcf73\/relationships\/field_tags?resourceVersion=id%3A16"}}}},{"type":"node--article","id":"95c0f6c6-7334-414c-b94a-9cbd13234ebd","links":{"self":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/95c0f6c6-7334-414c-b94a-9cbd13234ebd?resourceVersion=id%3A17"}},"drupal_internal__nid":6,"drupal_internal__vid":17,"langcode":"en","revision_timestamp":"2023-02-07T23:47:59+00:00","revision_log":null,"status":true,"title":"test 2","created":"2023-02-07T23:47:45+00:00","changed":"2023-02-07T23:47:59+00:00","promote":true,"sticky":false,"default_langcode":true,"revision_translation_affected":true,"path":{"alias":null,"pid":null,"langcode":"en"},"body":{"value":"\u003Cp\u003Etest 2\u003C\/p\u003E","format":"basic_html","processed":"\u003Cp\u003Etest 2\u003C\/p\u003E","summary":""},"comment":{"status":2,"cid":0,"last_comment_timestamp":1675813679,"last_comment_name":null,"last_comment_uid":1,"comment_count":0},"node_type":{"type":"node_type--node_type","id":"18971097-f4d9-44c8-a643-8546d9d09652","meta":{"drupal_internal__target_id":"article"}},"revision_uid":{"type":"user--user","id":"2983dfbb-a8bf-460f-85cc-ceac0d1e248a","meta":{"drupal_internal__target_id":1}},"uid":{"type":"user--user","id":"2983dfbb-a8bf-460f-85cc-ceac0d1e248a","meta":{"drupal_internal__target_id":1}},"field_image":{"data":null,"links":{"related":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/95c0f6c6-7334-414c-b94a-9cbd13234ebd\/field_image?resourceVersion=id%3A17"},"self":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/95c0f6c6-7334-414c-b94a-9cbd13234ebd\/relationships\/field_image?resourceVersion=id%3A17"}}},"field_tags":{"data":[],"links":{"related":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/95c0f6c6-7334-414c-b94a-9cbd13234ebd\/field_tags?resourceVersion=id%3A17"},"self":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article\/95c0f6c6-7334-414c-b94a-9cbd13234ebd\/relationships\/field_tags?resourceVersion=id%3A17"}}}}],"links":{"self":{"href":"https:\/\/drupal-api.ddev.site\/jsonapi\/node\/article"}}}

    I think the trouble getting the correct about may be something with your configuration.

    As for getting an individual resource JSONAPI expects the format http://example.com/jsonapi/{entity_type_id}/{bundle_id}/{entity_uuid} where entity_uuid is the uuid not the nid. To get a resource by nid try this format http://example.com/jsonapi/node/article?filter[drupal_internal__nid]=5

  • 🇮🇩Indonesia yalasta

    I have same issue, fresh installation of 10.0.3, every get request /jsonapi/node/article or /jsonapi/user/user get same error response (500) with details "Expected a scalar value as a 2nd argument to \"Symfony\\Component\\HttpFoundation\\InputBag::get()\", \"array\" given."

  • 🇮🇩Indonesia yalasta

    I found out jsonapi extras module caused this problem, this patch will fix it https://www.drupal.org/project/jsonapi_extras/issues/3331874 🐛 $request->get may no longer return array as of Symfony 6.0 Fixed

  • Status changed to Needs work about 1 year ago
  • 🇪🇸Spain rteijeiro

    Reopening this issue as I'm getting the same error when trying to access a single node using /jsonapi/node/page/1 end point in a GET request. It actually works when accessing all nodes of one type using /jsonapi/node/page in a GET request. I'm not using jsonapi_extras module or anything else but jsonapi and serialization modules in core. Just created a Basic Page for testing.

    The error I get is the same described in the issue title:

    {"title":"Not Found","status":"404","detail":"The \u0022entity\u0022 parameter was not converted for the path \u0022\/jsonapi\/node\/page\/{entity}\u0022 (route name: \u0022jsonapi.node--page.individual\u0022)"

    I assume the issue is related to the parameter "1" encoding or something but can't see anything in the documentation.

  • Status changed to Closed: works as designed about 1 year ago
  • 🇪🇸Spain rteijeiro

    My bad, I was using the node id instead the uuid as specified in the documentation. Closing again.

  • 🇬🇧United Kingdom rajjubajra

    I found "JSON API Defaults" caused this problem. after uninstalling "JSON API Defaults" it worked.

Production build 0.69.0 2024