Skip to content

Invalid Patch request body format required (most likely user error) #655

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
martinmike2 opened this issue Dec 11, 2019 · 6 comments · Fixed by #714
Closed

Invalid Patch request body format required (most likely user error) #655

martinmike2 opened this issue Dec 11, 2019 · 6 comments · Fixed by #714
Labels

Comments

@martinmike2
Copy link

Description

Either I am doing something incorrectly (likely), or there is an inconsistency with PATCH request required format (unlikely). I also realize that I am operating with an alpha version, and as such things might be goofy.

I am having a few issues, but the salient issue for this post is that I can't get a PATCH request to result in a deserialized type with the format specified in the json:api spec 1.0

Expected format per spec:
{ "data": { "type": "users", "id": 10, "attributes": { "userType": "Employee" } } }
This format actually results in a null type being presented to the JsonApiController PatchAsync method.

Actual format required to get a deserialized type that contains the value presented in the userType property (:
{ "type": "users", "id": "10", "userType": "Employee" }

All other imagined variations of the request body format either result in null types or types with default values that do not reflect the values passed in the request body.
...

Environment

  • Targeted Version: .netcore3.0
  • JsonApiDotNetCore Version: 4.0.0-alpha4
  • Other Relevant Package Versions:
    -- Microsoft.AspNetCore.Mvc.NewtonsoftJson: 3.1.0
    -- Newtonsoft.Json: 12.0.3
@wisepotato
Copy link
Contributor

are you sure you're also adding the application/vnd.api+json value for the Content-Type header.

@wisepotato
Copy link
Contributor

if so, if you can make a test that simulates the issue, we can start work on it very quickly.

@maurei
Copy link
Member

maurei commented Dec 23, 2019

I would expect this to be an issue with the content type, indeed. Any update on this?

@N1ghtStorm
Copy link

N1ghtStorm commented Dec 24, 2019

The problem really occurs when you dont write "id" section in request(it was possible in 3 version):

image

When field "id" is present in the request and is not 0 the problem dissapears
Ofc i use application/vnd.api+json value for the Content-Type

@maurei
Copy link
Member

maurei commented Feb 12, 2020

If I remember correctly we changed the "id" member to be required as it required by the spec. Nevertheless the error should be more clear when when this occurs, it shouldn't just fall back on a reply with regular json output content

@bart-degreed
Copy link
Contributor

@martinmike2 Can you please verify if #699 fixes your problem?

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.

5 participants