Reputation: 127
I have a wcf REST Service which is calling a method that updates something in the database. The method takes a parameter.
lets say my is void MarkMobileAppApplicationAsCancelled(string applicationId);
Now I am trying to invoke that service using one app from chrome app store called CREST. but I dont know how to invoke that method in Json format.
Any help??
I have some thing like
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/MarkMobileAppApplicationAsConfirmed/")]
void MarkMobileAppApplicationAsConfirmed(string applicationId);
what i am trying is initialize this method which will update my database by setting the application's application_confirmed = true,
I wrote the following in the Request Builder
https://local.blaSys.com/MobileAppWCF.svc/MarkMobileAppApplicationAsCancelled/
and the following in the header
content-type:application/json
Now, what would i write in the Request Entity??
Upvotes: 0
Views: 165
Reputation: 15086
Most likely you would not want to write anything in the request, but rather get the applicationID
from the url.
You can obtain this by using a slight modification
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/MarkMobileAppApplicationAsConfirmed/{applicationID}")]
void MarkMobileAppApplicationAsConfirmed(string applicationId);
Now you can simply make a standard http request (using curl/fiddler for testing and WebClient/WebRequest) in the proxy against the endpoint
https://local.blaSys.com/MobileAppWCF.svc/MarkMobileAppApplicationAsCancelled/someApplicationId
Remember that the method given to the request must be POST
as indicated in the WebInvoke
attribute. (I guess a PUT
would be more idiomatically correct since you must be updating a method, but that is another discussion.)
Hope this helps!
Upvotes: 1