JSON:API generates 404 when it can't find an entity reference

Created on 19 February 2024, 4 months ago
Updated 13 May 2024, about 1 month ago

Problem/Motivation

I've been trying to upload some new nodes to a D10.1.19 site when I started getting lots of 404 errors. This was confusing for half a day because the URL (http://site.name/jsonapi/node/type) would work okay in the browser.

A big part of the problem is that my code would only report the 404 error to me without the extra field of detail that is nicely provided in the full response. The log pages on Drupal also only showed "Page not found".

I only discovered this extra clue when I tried to replicate the POST from the command line with a CURL command. This told me, ""detail":"The resource identified by `node--b:10fa0e59-028b-42a7-b45a-b07b7fed24fa` (given as a relationship item) could not be found."

Is a 404 error the best response to bad data in the POSTed JSON? I get 422 when some of the data is misformatted. Is it possible to include this extra detail in the log entry? I think this might save a future version of me more time.

Thanks for everything.

🐛 Bug report
Status

Active

Version

10.1

Component
JSON API 

Last updated 1 day ago

Created by

🇺🇸United States bogdog400

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

Comments & Activities

Production build 0.69.0 2024