Best choice for calling REST endpoint

Aug 1, 2011 at 7:57 PM


Just interested what you thoughts or plans are for the Communications library with respect to calling REST services where the StatusCode is important to bubble up along with the response. The ResourceClient seems appears to not currently expose that property, only returning the deserialised response. Is the RestClient the expected choice here with ResourceClient aimed more at POX or SOAP calls?.

RestSharp is an obvious alternative outside of WP7Contrib but wondered if I'm missing something first before pulling in a separate library.



Aug 1, 2011 at 10:08 PM
Edited Aug 1, 2011 at 10:10 PM


Your right ResourceClient is aimed at POX\SOAP calls, we don't expose the status code unless there is failure with the communication. The RestClient is better suited to giving access to the status codes I believe but I'm not the author of this.

I believe the RestSharp OSS is going to give a more complete implementation.

Can you give an example of where you want access to the status code? I would be interested in hearing about this and possible exposing as required.

Aug 1, 2011 at 10:25 PM


Thanks for the response. I'll look at the Restsharp library for the time being then. The example for why I need the status code is that the particular REST API I'm calling, an internal one so I can't give you a link, uses the status code to respond with different 'valid' responses. So 200 is 'thing' success, 404 is 'thing' not found, 410 is thing something else. All of those would result in a different decision in the consuming logic and most likely a different response to the user.

Hope that helps,


Aug 2, 2011 at 8:55 AM

We do expose status codes when the response is not 200, this is done as an exception, ResourceClientStatusException. This version of silverlight only exposes a subset of the HTTP status codes and these are only returned when attempt to access the response stream, at this point a WebException is thrown, we catch and convert into a ResourceClientStatusException.