This is the situation:
Their is a external webservice in Servoy and I want to use this service in a ASP.NET MVC applicatie.
With this code I attempt to get the data from the service:
HttpResponseMessage resp = client.GetAsync("http://localhost:8080/servoy-service/iTechWebService/axws/shop/_authenticate/mp/112818142456/82cf1988197027955a679467c309274c4b").Result;
var foo = resp.Content.ReadAsAsync<string>().Result;
No MediaTypeFormatter is available to read an object of type 'String'
from content with media type 'text/plain'.
Try using ReadAsStringAsync() instead.
var foo = resp.Content.ReadAsStringAsync().Result;
The reason why it
ReadAsAsync<string>() doesn't work is because
ReadAsAsync<> will try to use one of the default
XmlMediaTypeFormatter, ...) to read the content with
text/plain. However, none of the default formatter can read the
text/plain (they can only read
ReadAsStringAsync(), the content will be read as string regardless of the content-type.