I have some sample JSON I want to post to my WebAPI fo testing but I cannot see to get it to deserilaize my object I am passing in.
Here is my form:
<form action="/api/orders" method="post" >
<textarea type="text" id="order" name="order"></textarea>
<input type="submit"/>
</form>
Here is my method:
[HttpPost]
public HttpResponseMessage Post(Model.Order order)
{
var response = Request.CreateResponse<Order>(HttpStatusCode.Created, order);
string uri = Url.Link("DefaultApi", new { id = order.OrderID });
response.Headers.Location = new Uri(uri);
return response;
}
Here is what I paste in the form for submission:
{
"ShipToContactPhone" : "9999999999",
"ContactPhone" : "9999999999",
"IsPlaced" : 0,
"ContainerName" : null,
"Terms" : "3",
"ShipDate" : null,
"OrderGUID" : "6D55FB6E-36A2-43F3-8316-2BE740ACC8E1",
"CatalogName" : null,
"ShipToCountry" : "USA",
"SalesRepID" : 0,
"OrderType" : null,
"ShipVia" : null,
"IsContainer" : null,
"BillingAddress1" : "TEST ACCOUNT",
"BillingCity" : "BROOK",
"CustomerID" : 721182,
"BillingAddress2" : "",
"OrderStatus" : "Accept",
"TaxTotal" : 0,
"Source" : null,
"Discount" : 0,
"OrderDate" : "3\/8\/13",
"CustomerNumber" : "26",
"OrderTotal" : 2160,
"ShippingTotal" : 0,
"ShipToZip" : "07663",
"CurrencyCode" : "USD",
"TaxRate" : 0,
"Origin" : null,
"CancelDate" : null,
"WrittenByName" : "(null)",
"BillingState" : "NJ",
"Exported" : null,
"ShipToAddress1" : "6 ANYWHERE STREET",
"ShipToAddress2" : "",
"Notes" : "",
"FreightTerm" : null,
"ShipToContactEmail" : "test@test.com",
"ContactEmail" : "test@test.com",
"ShipToFax" : "9999999999",
"ContactName" : "",
"PONumber" : "",
"ShipToContactName" : null,
"WrittenForName" : null,
"CatalogCode" : null,
"ManufacturerID" : 3456,
"ShipToCompanyName" : "TEST",
"ShipToState" : "NJ",
"isDefault" : 1,
"PriceLevel" : 5,
"ShipToCity" : "BROOK",
"ContainerCubes" : 0,
"WrittenForRepnumber" : null,
"MarketName" : "",
"DoNotShipBefore" : null,
"RepNumber" : null,
"FOB" : null,
"IsDeleted" : null,
"SubTotal" : 0,
"ContactFax" : "9999999999",
"BillingZip" : "07663",
"CustomerName" : "TEST",
"ExportDate" : null,
"OrderID" : 0,
"WrittenForRepNumber" : null,
"BillingCountry" : "USA"
}
I think this is probably because the content-type is not application/json
coming from the form.
How can I simply test this and get it working?