cerebris / jsonapi-resources

A resource-focused Rails library for developing JSON:API compliant servers.
http://jsonapi-resources.com
MIT License
2.32k stars 529 forks source link

More Helpful Error Messages for Relationship Type Mismatches #807

Open jherdman opened 8 years ago

jherdman commented 8 years ago

I encountered the following error today: "{"errors":[{"title":"Type Mismatch","detail":"category is not a valid type for this operation.","code":"116","status":"400"}]}". My Ingredient resources has a belongs-to relationship to Category. Eventually through Dan Gebhardt's help I came to realize that I should have been using the plural name of the resource in my request.

It'd be nice to have a more helpful error message when such an error occurs. Imagine my error message also included a list of valid types, e.g. "Valid types include 'categories', 'cars', 'sith-lords'." Perhaps this would only apply in dev mode, though it may not hurt in prod too.

evolve2k commented 7 years ago

I'm having the same sort of issue.

My error message is {"errors":[{"title":"Missing Parameter","detail":"The required parameter, data, is missing.","code":"106","status":"400"}]}

My request was:

{"data":{"type":"income-items", "attributes":{"name":"","amount":"","frequency":1,"nextDueAt":""},"relationships":{"worksheet":{"data":{"id":"13","type":"worksheets"}}}}}

No idea where it thinks data is missing.

Anyone have any light to shed?

webdev778 commented 7 years ago

I am too. is there any solution?

ildarusmanov commented 6 years ago

I have the same issue :(