RestSharp post object to WCF

Posted by steve on Stack Overflow See other posts from Stack Overflow or by steve
Published on 2012-04-01T17:25:31Z Indexed on 2012/04/01 17:30 UTC
Read the original article Hit count: 317

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about wcf

Related posts about http