restsharp/RestSharp — Issue #205: When the content-type is not corresponding to the data
Author: CGUGileno
Created: 2012-01-19 22:55:11+00:00
State: open

Hi,

I have a situation where I request data from a url, the context-type is text/xml, but the data returned is text/json.

As showed on Wiki, I tried to override the default deserializer text/xml doing this:

client.ClearHandlers();
client.AddHandler("text/xml", new RestSharp.Deserializers.JsonDeserializer());

But I haven't got my class populated.

The Data returned from the url: http://www.swellmap.com/ajr.php?r=plugin&s=mana-island&a=Boating

Result:

HTTP/1.1 200 OK
Date: Thu, 19 Jan 2012 22:30:39 GMT
Server: Apache/1.3.34 Ben-SSL/1.55 (Ubuntu) PHP/5.2.3-0.dotdeb.1 with Suhosin-Patch AuthMySQL/4.3.9-2 mod_perl/1.29
Vary: Host
X-Powered-By: PHP/5.2.3-0.dotdeb.1
Set-Cookie: PHPSESSID=d547cab5e3918d8fc192492024582c24; path=/
Expires: Sat, 1 Jan 2000 00:00:00 GMT
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Last-Modified: Thu, 19 Jan 2012 22:30:39GMT
Transfer-Encoding: chunked
Content-Type: text/xml; charset=utf-8

31f
({"forecastdate":"12h","rating":"","summary":"","tides":"","seatemp":"-273°C","title":"mana-island","smaplink":"http:\/\/www.swellmap.com\/boating\/\/mana-island","vars":{"bhs":{"value":"1.3","title":"Sea","unit":"m"},"bhssw":{"value":"0.9","title":"Swell","unit":"m"},"hs_sea":{"value":"0.9","title":"Chop","unit":"m"},"tp":{"value":"8","title":"Period","unit":"s"},"dpm":{"value":"E","title":"Swell dir","unit":""},"dpm_sea":{"value":"--","title":"Sea dir","unit":""},"windma":{"value":"N 5","title":"Wind","unit":"kts"},"gstma":{"value":"6","title":"Gusts","unit":"kts"}}})
0

To make it simple, for while, my class is just:

public class WeatherData
{
public string ForecastDate { get; set; }
}