Problem/Motivation

The following request is working fine in jsonapi 1.x

/jsonapi/field_config/field_config
?filter[special-fields][condition][path]=field_type
&filter[special-fields][condition][operator]=IN
&filter[special-fields][condition][value][]=entity_reference
&filter[special-fields][condition][value][]=datetime
&filter[special-fields][condition][value][]=boolean
&filter[translatable][value]=true
&filter[entity_type][value]=node
&fields[field_config--field_config]=bundle,field_name

But is no longer working in 2.x

The problematic part seems to be related to

?filter[special-fields][condition][path]=field_type
&filter[special-fields][condition][operator]=IN
&filter[special-fields][condition][value][]=entity_reference
&filter[special-fields][condition][value][]=datetime
&filter[special-fields][condition][value][]=boolean

I checked the jsonapi documentation for filters and it seems the syntax is correct. Is the documentation out of date, or is this a bug?

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

dagmar created an issue. See original summary.

wim leers’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +API-First Initiative

What response do you receive? Knowing that will allow me to help you better, and determine whether it’s a bug.

dagmar’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new25.04 KB

@Wim Leers. Thanks for your response. I get an empty data array

wim leers’s picture

StatusFileSize
new587 KB

Hm … weird, because your exact query works just fine for me, on a fresh D8 install with Umami + JSON:API:

I suspect this is a user agent/URL handling problem, because I can get this from the command line:

$ http GET http://d8/jsonapi/field_config/field_config?filter[special-fields][condition][path]=field_type&filter[special-fields][condition][operator]=IN&filter[special-fields][condition][value][]=entity_reference&filter[special-fields][condition][value][]=datetime&filter[special-fields][condition][value][]=boolean&filter[translatable][value]=true&filter[entity_type][value]=node&fields[field_config--field_config]=bundle,field_name Accept:application/vnd.api+json
[1] 48188
[2] 48189
[3] 48190
[4] 48191
-bash: filter[special-fields][condition][operator]=IN: command not found
[5] 48192
-bash: filter[special-fields][condition][value][]=entity_reference: command not found
-bash: filter[special-fields][condition][value][]=datetime: command not found
[6] 48193
-bash: filter[special-fields][condition][value][]=boolean: command not found
[7] 48194
-bash: filter[translatable][value]=true: command not found
-bash: filter[entity_type][value]=node: command not found
-bash: Accept:application/vnd.api+json: No such file or directory
[2]   Exit 127                filter[special-fields][condition][operator]=IN
[3]   Exit 127                filter[special-fields][condition][value][]=entity_reference
[4]   Exit 127                filter[special-fields][condition][value][]=datetime
[5]   Exit 127                filter[special-fields][condition][value][]=boolean
[6]-  Exit 127                filter[translatable][value]=true
[7]+  Exit 127                filter[entity_type][value]=node

wim.leers at acquia in ~/Work/d8/modules/jsonapi on 8.x-2.x [?]
$ HTTP/1.1 200 OK
Cache-Control: must-revalidate, no-cache, private
Connection: Keep-Alive
Content-Length: 252
Content-Type: application/vnd.api+json
Content-language: en
Date: Fri, 23 Nov 2018 09:32:49 GMT
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.23 (Unix) PHP/7.0.12
Vary: 
X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
X-Drupal-Cache: MISS
X-Drupal-Cache-Contexts: url.query_args:fields url.query_args:filter url.query_args:include url.query_args:page url.query_args:sort url.site
X-Drupal-Cache-Tags: config:field_config_list http_response
X-Drupal-Dynamic-Cache: HIT
X-Frame-Options: SAMEORIGIN
X-Generator: Drupal 8 (https://www.drupal.org)
X-Powered-By: PHP/7.0.12
X-UA-Compatible: IE=edge

{
    "data": [],
    "jsonapi": {
        "meta": {
            "links": {
                "self": {
                    "href": "http://jsonapi.org/format/1.0/"
                }
            }
        },
        "version": "1.0"
    },
    "links": {
        "self": {
            "href": "http://d8/jsonapi/field_config/field_config?filter%5Bspecial-fields%5D%5Bcondition%5D%5Bpath%5D=field_type"
        }
    }
}


[1]+  Done                    http GET http://d8/jsonapi/field_config/field_config?filter[special-fields][condition][path]=field_type

wim.leers at acquia in ~/Work/d8/modules/jsonapi on 8.x-2.x [?]

In this case, only the first ?filter[…SOMETHING…] parameter actually reaches the server. Note how the response looks exactly like yours!

dagmar’s picture

Status: Active » Closed (works as designed)

Thanks @Wim Leers. I'm sorry I was trying a different endpoint and indeed that endpoint should return an empty array in my case. Sorry about the confusion.

wim leers’s picture

Status: Closed (works as designed) » Fixed

Great! And no worries :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.