-
Notifications
You must be signed in to change notification settings - Fork 107
Getting empty 'errors' result #48
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
Comments
Hmm, yes, agree. What is the HTTP status code when you get these errors? (That will help me track down where it's coming from). |
When we send an id for a nonexistent record, we receive an empty errors[] and 404 status. |
Ok, thanks for the pointers. The one proviso I'd say about all of this is that there is no requirement in the spec to send an error object - i.e. an empty errors array is valid. E.g. in the However, as far as I can remember there is a way to customise this in your error config though so I'll check on that and get back to you. |
I do get a "404 Not found" response code. In my case, I am getting this on a relationship link. So, the base object exists but then when I follow the relationship link I get "404 not found". Probably there is something with my work that is causing it, I just don't know where the failure occurs. Relationship links on other models do work fine. One thing which comes to mind, my 'id' on the country object below is alphabetical, using the UN codes for countries (ex. Canada = "CA", United States = "US"). If that is a problem I'll switch to numeric IDs however it works fine with Laravel Eloquent. The direct URL to a country with alphabetic 'id' works fine. Also, I am using 'country-divisions' for the name of provinces/states/etc. in the JSON API but the relationships in Eloquent are called 'division()'. I think I have that set up right but not sure, however it shouldn't apply in this specific case I don't think since I'm calling the 'country()' relationship. Base URL (works): Relationship URL (get 404 error): Direct link works |
@SirLamer non-numeric keys should work fine, we're using UUIDs for some of our resources in one of our apps. The relationship that isn't working, have you added it to the properties on your |
Okay that is it, but this is a "belongsTo" relationship so if all relationships should go in there then it should be renamed. Same with "hasMany" and "belongsToMany". Just call it "singularRelationships" and "pluralRelationships" or something like that. |
They are |
OOOHHHHHHHHHH okay then! I wonder if maybe the comment on the My initial understanding took the assumed perspective of something like "I guess they need to know these ones because the ID reference to this model is stored in other models, so they need to know what to look up." |
@SirLamer yes you're right, it's not actually very clear at the moment. For info we're planning on moving the definition of which relationships should be exposed as endpoints to the route registration. The detail of what is going to change is here: |
Closing this as the routing refactor allows control of what routes are registered - currently on |
I have a case where the API is returning 'errors' with an empty array. Since it's handled by the API and not the exception handler, error tracing this is very difficult. I suspect it is an error event for which no message is provided in the default config.
I am not familiar enough with this package to trace the error generation at this time, otherwise I might try to provide a better hint!
So, two suggestions:
If there are error events without a message, maybe they should be added to the json-api-errors.php?
Perhaps a default error message should be provided, and when this default is used a log dump to the server log file should occur?
The text was updated successfully, but these errors were encountered: