printdotio / printio-api

Issues + wiki for the api. See http://print.io/api
0 stars 0 forks source link

Response of 200 Validation Error #29

Open seanwooj opened 9 years ago

seanwooj commented 9 years ago

I sent a post to products, with all fields correct except for the email, which was in a bad format. I got a response I expected, which was one that returned and error_id and an error explanation, but it still came back as a 200. My http wrapper uses a method .ok? which relies on the response codes, so it will record a successful transaction even though there are errors.

Is it intentional to return a 200 when there are errors, or should it be a different code? I can easily change the method to check for an error explanation, but I am not sure if this is actually the desired behavior or not.

Thanks a lot!

micahasmith commented 9 years ago

It is intentional to return 200, so that its easy to parse out the reasons why in the json response. Not all clients can parse the body of a non-200 status, thus our design choice here.

See the "Error Handling" section on http://print.io/api to see how we do error responses.

Note that our server will do a 500 if there is an internal error, which is incredibly rare (but still possible).