RestSharp post object to WCF
- by steve
Im having an issue posting an object to my wcf rest webservice.
On the WCF side I have the following:
[WebInvoke(UriTemplate = "", Method = "POST")]
public void Create(myObject object)
{
//save some stuff to the db
}
When im debugging this never gets hit - it does however get hit when I remove the parameter so im guessing ive done something wrong on the restSharp side of things.
Heres my code for that part:
var client = new RestClient(ApiBaseUri);
var request = new RestRequest(Method.POST);
request.RequestFormat = DataFormat.Xml;
request.AddBody(myObject);
var response = client.Execute(request);
Am I doing this wrong? How can the WCF side see my object? What way should I be making the reqest? Or should I be handling it differently WCF side?
Things ive tried:
request.AddObject(myObject);
and
request.AddBody(request.XmlSerialise.serialise(myObject));
Any help and understanding in what could possibly be wrong would be much appreciated. Thanks.