Forum C# Question about Web.Get/Web.Post

Question about Web.Get/Web.Post

Postby HVStudios » September 10th, 2013, 7:42 pm

I'm currently using Web.Get to verify purchases with Amazon. Amazon uses HTTP status codes as responses to verification requests. For example, 200 is success, 499 is renew, 497 & 498 mean invalid purchase, etc.

I was testing invalid purchases and I noticed that when Amazon's server returns anything other than 200, the "errorCallback" is called instead of "successCallback". In a way this makes sense, but I had thought that the "errorCallback" was simply for PlayerIO errors, not also successful network communications that contain non-success HTTP status codes.

My question is, if I use Get without specifying an errorCallback, will all server responses go through the successCallback? Or are they just ignored because no error callback is specified? If I must use an errorCallback to handle non-200 response codes, how can I get the HttpResponse object from the PlayerIOError object?

EDIT: I guess more generally, is "successCallback" only called if the response status code from the server is 200? What status codes trigger a "successCallback" vs. an "errorCallback"?
HVStudios
Paid Member
 
Posts: 20
Joined: July 30th, 2013, 7:15 pm

Re: Question about Web.Get/Web.Post

Postby Henrik » September 11th, 2013, 6:18 pm

Yes, if you omit the errorcallback, you'll simply to be notified of errors. And yes, success is called on 200, and error on everything else, since every other status code is technically an error. :-)
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Question about Web.Get/Web.Post

Postby HVStudios » September 11th, 2013, 6:45 pm

While it makes sense that the errorCallback would be called for non-200 responses, I'd argue that it should be possible to retrieve the HttpResponse object from the PlayerIOError object so that I can respond to the StatusCode value. Is there a way in PlayerIOError to differentiate between an error within PlayerIO vs. the external server returning an error code?

As it stands, when I get a non-200 response, I have to parse the error message to get the StatusCode, which is definitely more error-prone than just having access to the StatusCode int field.
HVStudios
Paid Member
 
Posts: 20
Joined: July 30th, 2013, 7:15 pm


Return to C#



cron