Search code examples
c#.netwcfvisual-studio-2010wcf-client

InternalServerError (500) using consuming REST services using WCF Rest Starter Kit


I recently downloaded the WCF Rest Starter Kit and attempted to connect to a REST service written in Java.

I can browse to the url of the service and the browser spits out xml. However, I get a InternalServerError when attempting to connect via the HttpClient object. Does anyone have any ideas?

_uri = @"http://mytestservice";            
HttpClient http = new HttpClient(_uri);

http.TransportSettings.UseDefaultCredentials = true;

HttpResponseMessage response = http.Get();
response.EnsureStatusIsSuccessful();

Solution

  • Adding the following to the default headers did the trick.

    http.DefaultHeaders.Accept.Add("application/xml");