I am using the WCF REST Template to test out REST Development. I am trying to test a POST Method defined like this:
[WebInvoke(UriTemplate = "", Method = "POST")] public SampleItem Create(SampleItem instance) { // TODO: Add the new instance of SampleItem to the collection return new SampleItem() { Id = 1, StringValue = "Hello Post" }; } However I cant figure out how to get it to accept my SampleItem Parameter. I am using fiddler to submit a POST Request to http://ipv4.fiddler:54916/service1 with the following Header:
User-Agent: Fiddler Host: ipv4.fiddler:54916 I have tried the following two solutions for the Request Body:
SampleItem.Id=1&SampleItem.StringValue=TestValue AND
<SampleItem xmlns="http://schemas.datacontract.org/2004/07/PerTrac.Cloud.Service.Statistic"> <Id>2147483647</Id> <StringValue>String content</StringValue> </SampleItem> However all I am able to get back is a 400 error.
SampleItem looks like this:
// TODO: Edit the SampleItem class [DataContract] public class SampleItem { [DataMember] public int Id { get; set; } [DataMember] public string StringValue { get; set; } } How can I pass SampleItem to the service without getting a 400 error ???