Serialization of default values Web Api and Json.NET

If you’re using ASP.NET Web Api and some properties isn’t serialized when serializing to json if the value is default value. An example is when bool properties with false as value not are serialized try to add the following code in the Register method of the WebApiConfig class. config.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;

  3/2/2015 - 2:09 PM

415 Unsuported media type

A common error when posting JSON to a WebAPI service is “415 Unsupported Media Type”. When posting JSON with HttpClient you added your JSON to StringContent and using Uri and StringContent as argument for PostAsync. The code below resulting in above mentioned error. var content = new StringContent(json); await client.PostAsync(uri, content); The first thought is […]

  4/22/2014 - 2:28 PM

Authentication for REST calls with HTTPClient to Azure MobileServies

In a current project I working with an app that uses a .NET Backend in Azure Mobile Services. Backend is a WebAPI. On client side I have all the code for networking in portable class library so I can reuse it on other platforms. Right now we are building the app for Windows Phone, but […]

  4/17/2014 - 9:47 AM