From Service.svc.cs, you can find the class that is used as the resource for the service, which is just the Counter class. The xml for this that you can paste in a fiddler request is:
<Counter><Value>42</Value></Counter>
Make sure you set the Content-Type to text/xml. Whatever value you specify will be used to update this object at the service.
In general, with these samples, it might take a bit of sleuthing to figure out what to send in a POST, but if you start with the class that you are trying to modify, figuring out the xml is usually pretty straightforward. Let me know if you want example
xml for any of the other samples.
Alternatively, a bunch of the samples have json handlers, so the POST could take a totally different form. But if you start with the class that is being serialized, you'll get the right format pretty quickly.
Perhaps I should have guessed that the request body for the POST would use the same format as the response from the GET. I'm new to the actual workings of HTTP despite over 10 years writing C++/C# code. I'm always amazed by the amount to knowledge these
types of starter kits presuppose.
BTW, I'd like you to get credit, so how do I mark this as "answered" (I'm new to these forums too).
ljc
0 Points
2 Posts
sample "Counter" - request body for post
Jan 29, 2009 09:14 PM|LINK
How do I determine what the request body should be for a POST when using the Counter sample that's contained in the starter kit?
WCF REST Starter Kit
James Osborn...
Member
70 Points
30 Posts
Re: sample "Counter" - request body for post
Jan 29, 2009 10:35 PM|LINK
From Service.svc.cs, you can find the class that is used as the resource for the service, which is just the Counter class. The xml for this that you can paste in a fiddler request is:
<Counter><Value>42</Value></Counter>
Make sure you set the Content-Type to text/xml. Whatever value you specify will be used to update this object at the service.
In general, with these samples, it might take a bit of sleuthing to figure out what to send in a POST, but if you start with the class that you are trying to modify, figuring out the xml is usually pretty straightforward. Let me know if you want example xml for any of the other samples.
Alternatively, a bunch of the samples have json handlers, so the POST could take a totally different form. But if you start with the class that is being serialized, you'll get the right format pretty quickly.
ljc
0 Points
2 Posts
Re: sample "Counter" - request body for post
Jan 30, 2009 07:04 PM|LINK
Thanks, your suggestion worked.
Perhaps I should have guessed that the request body for the POST would use the same format as the response from the GET. I'm new to the actual workings of HTTP despite over 10 years writing C++/C# code. I'm always amazed by the amount to knowledge these types of starter kits presuppose.
BTW, I'd like you to get credit, so how do I mark this as "answered" (I'm new to these forums too).
WCF REST Starter Kit
James Osborn...
Member
70 Points
30 Posts
Re: sample "Counter" - request body for post
Feb 04, 2009 05:20 PM|LINK
I've been told there's a way to mark a post as answered. I have not found it yet, so don't worry too much about it.