Skip to content

Sending an empty fields parameter results in error #996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bart-degreed opened this issue May 11, 2021 · 0 comments · Fixed by #1009
Closed

Sending an empty fields parameter results in error #996

bart-degreed opened this issue May 11, 2021 · 0 comments · Fixed by #1009
Assignees
Labels

Comments

@bart-degreed
Copy link
Contributor

From the spec at https://jsonapi.org/format/1.1/#fetching-sparse-fieldsets:

The value of any fields[TYPE] parameter MUST be a comma-separated (U+002C COMMA, “,”) list that refers to the name(s) of the fields to be returned. An empty value indicates that no fields should be returned.

But when sending the next request:

GET /blogPosts?fields[blogPosts]= HTTP/1.1

An error message is returned:

{
  "id": "fc58e77d-b09c-4cbb-a9a7-2f20370cbf82",
  "status": "400",
  "title": "Missing query string parameter value.",
  "detail": "Missing value for 'fields[blogPosts]' query string parameter.",
  "source": {
    "parameter": "fields[blogPosts]"
  }

This is easily worked around by instead sending:

GET /blogPosts?fields[blogPosts]=id HTTP/1.1

But for correctness, we should allow it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

1 participant