question

helios825 avatar image
0 Likes"
helios825 asked

Finding API - Error Handling & HTTP Error Codes

I'm doing some coding at the moment for error handling of calls to the Finding API. I'm intentionally introducing some errors -- invalid GlobalID, invalid AppID, invalid Category, etc. -- to capture the error responses from eBay's API, so that my code can gracefully handle these, and other, hopefully-rare situations once my code is live and in the wild. What's surprising me is that the eBay API is returning the XML error message with an HTTP error code of 500. Is that proper? Has it always been that way? I would have expected the usual HTTP code 200, since there's really no HTTP error present, and normal XML is being sent back from eBay. The API call error I'm generating isn't at the HTTP layer. Here's a URL with a bad AppID to try. Look at your HTTP headers on the response to see error 500: http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-NAME=FindingService&SERVICE-VERSION=1.12.0&SECURITY-APPNAME=BadAppId&RESPONSE-DATA-FORMAT=XML&GLOBAL-ID=EBAY-US&REST-PAYLOAD&keywords=gold (Sidenote: in the returned headers, there seems to also be a weird typo (even changing with each refresh) on the "Connection: Close" line. There's also a "Connection: keep-alive" line there too, seemingly in conflict.) I guess I could code around this error 500, but I already have call handling routines to treat it properly, and I'd rather not have to disturb that if at all possible. Thanks.
finding apierror handlingerror codeshttp error
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

helios825 avatar image
0 Likes"
helios825 answered
Also, shouldn't the error response be nested within proper findItemsAdvancedResponse XML tags, with an ack=Failure and all the other trimmings?
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

helios825 avatar image
0 Likes"
helios825 answered
After a little more testing, I'm seeing 2 kinds of error responses: 1) The above behavior, when the error is relatively "low-level" -- wrong AppID or GlobalID, for example. 2) Proper behavior, when the error is more on the "call level" -- invalid category, or keyword of length=1, etc. This returns HTTP code 200, as well as the XML syntax that should be there, such as the encompassing findItemsAdvancedResponse nodes missing from the HTTP=500 example. Ok, this may have been the behavior all along, I'm just doing deeper testing this time around.
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

clickimusprime avatar image
0 Likes"
clickimusprime answered
Yeah I think you're see responses from two different handlers. One at the load balancer and one at the server processing the API response. The 10000+ codes are not documented under Finding API. Similar code was used by PayPal. I handle errors by: - Ignoring HTTP status - looking for errorMessage->error->message - checking for ack=Failure - then check for error->message - on 11002 errors, in either form, I rewrite the message text to prevent it leaking credentials if a programmer makes an error and sends the code direct to the users, since eBay put the APPID in the message text. The "Cneonction:close" stuff is most likely due to a load balancing check-summing technique: https://forums.aws.amazon.com/message.jspa?messageID=81954
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

helios825 avatar image
0 Likes"
helios825 answered
Thanks for the run-down, cp. I guess I'll have to make adjustments for these 2 kinds of error formats and varying HTTP status codes. That's pretty funny -- the hack logic behind the intentional misspelling of "Connection" in the header. Thanks for linking to that.
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.