Question: I am developing a simple windows phone 8 application.  

I do not use `MVVM`, it is very simple.  

I have a button, and when I press it I want to add some data into the database (using the post method).  

The web `API` is made in `asp.net` and it works properly because I tested with `fiddler`, and also with a console application.  

The code behind from the button is the following: 

```
private void Button_Click(object sender, RoutedEventArgs e)
    {
        HttpClient client = new HttpClient();
        string baseUrl = "myWebApiLink";
        client.BaseAddress = new Uri(baseUrl);
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

        string serviceUrl;
        serviceUrl = "api/People";

        var anEmployee = new People()
         {
             FirstName = "Windows",
             LastName = "Phone",
             Age = 8
         };
         HttpResponseMessage response;
         response = client.PostAsJsonAsync(serviceUrl, anEmployee).Result; //the problem
         if (response.IsSuccessStatusCode)
         {
             //some success messages
         }
         else
         {
             //some fail messages
         }
UriKind.Relative));
    }

```

At the line 

```
response = client.PostAsJsonAsync(serviceUrl, anEmployee).Result;  

```

the application just gets blocked.  

It does not throw an exception, it just stays on that line. 

Any ideas?

Thank you in advance!

Answer: 
By default the `XmlMediaTypeFormmatter` of Web API uses the `DataContractSerializer`.

When this serializer serializes auto-properties, it adds the infamous `xxx_BackingField` to the serialized properties. To avoid this you can do two different things:

* decorate all the autoproperties with `[DataMember]`, and keep using the default `DataContractSerializer`
* Change the xml media type formatter default serializer to use `XmlSerializer` instead. You can change the configuration in global.asax like this: `GlobalConfiguration.Configuration.Formatters.XmlFormatter.UseXmlSerializer = true;`
See [MSDN reference for XmlMediaTypeFormatter.UseXmlSerializer Property](http://msdn.microsoft.com/en-us/library/system.net.http.formatting.xmlmediatypeformatter.usexmlserializer%28v=vs.118%29.aspx) for more information.

Using an anonymous type, like suggested in the other answer, avoids the problem because the anonymous class doesn't have a `[DataContract]` attribute. The problem is that, with that option, you always have to use anonymous types, and that can require a lot of typing, and even be error prone.
When `Serializable` Attribute is required I always return an anonymous type.

```
public dynamic Me()
{
    var user = new LoggedInUser() { FirstName = "Test" };
    return new {FirstName = user.FirstName};
}

```