Reputation: 1407
My Code:
[DataContract(Namespace="http://yournamespace.com")
public class MyContract
{
[DataMember(Order=1)]
public string MyData1 { get(); set{};}
[DataMember(order=2)]
public string MyData2 { get(); set{};}
}
[WebInvoke(method="POST")]
public string DoSomethingFromPost(MyContract postedData)
{
String s="Success";
return s;
}
Request Input:
<MyContract xmlns="http://yournamespace.com">
<MyData1>value</MyData1>
<MyData2>value</MyData2>
</MyContract>
While Testing it in Rest Client i am getting 400 Bad Request. Please tell me how to test the post method in Rest Client.why i am getting 400 bad request.
Please tell me.........
Upvotes: 1
Views: 370
Reputation: 7876
You need to have your request as shown below for it to work:
<MyContract xmlns="http://yournamespace.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<MyData1>value</MyData1>
<MyData2>value</MyData2>
</MyContract>
When you get HTTP status code 400 then you can enable tracing on your service to know the exact reason for the bad request. To enable tracing follow this link
Upvotes: 1