ngx-jsonapi icon indicating copy to clipboard operation
ngx-jsonapi copied to clipboard

It is impossible to create a new resource when providing a client-generated ID

Open unterwegsmitkeks opened this issue 4 years ago • 3 comments

  • When I'm POSTing a new instance, the service I'm consuming checks if an ID is provided with the request.
  • If not it will generate an ID. If however I'm providing an ID, the service will use it as long as it is unique.

The request body with an ID should look like this:

{ "data": { "id": "my-own-id", "type": "atype", "attributes": { "foo": "bar" } } }

  • When sending this request through Postman, the result is status 200.
  • However, when using ngx-jsonapi, the service returns status 400.

unterwegsmitkeks avatar Aug 03 '20 07:08 unterwegsmitkeks

I have experienced the same issue.

The problem is that ngx-jsonapi is adding the id also to the url if it is present in the data. The url should be http://SERVER/api/atype instead of http://SERVER/api/atype/my-own-id.

kirkasius avatar Aug 04 '20 06:08 kirkasius

The bug is only the URL modification? Or you detect another bug?

pablorsk avatar Aug 04 '20 11:08 pablorsk

The bug is only the URL modification? Or you detect another bug?

My bad - I had actually detected the URL issue, too, but forgot to mention it in the bug description. It looks like that is the actual bug. Otherwise, the function is behaving as expected.

unterwegsmitkeks avatar Aug 05 '20 05:08 unterwegsmitkeks