The object required contains a string. When I pass in the string I receive an error. Is there a way to build up an object using XML in a SOAP request. According to my knowledge, SOAP requests have to be in XML format.
We have a dropwizard micro-services, and we need to access POST request body for one of end point in a filter.
How can I access Deserialize request body object in a Filter?
I have this JSON dictionary:
{"userId":"363008505", "userName":"almogsh11", "friends":[{"u":"2079823612","n":"she43"},{"u":"2010211025","n":"temy63c"}]}
It contains the "friends" array. I want to send this dictionary in post http request to server.
How can I do this?
You could use the AFNetworking framework. There are a couple of methods you could use, such as JSON Parameter Encoding and URL Form Parameter Encoding.
I am using RestSharp to do a REST API client application. If the format of request body (pay load) for a POST Rest Api call is JSON, I would like to know when I should use RestRequest.AddJsonBody() method and when RestRequest.AddObject() method. Thank you.
To send a JSON payload, use AddJsonBody. AddObject will extract name-value pairs from the object and add them as parameters.
I have seen some posts in stackoverflow saying "sending list of items in the GET Method, is NOT allowed. It has to be accomplished via POST method only"
My code looks like
[OperationContract]
[WebGet(UriTemplate = "Employee/{emp}",RequestFormat=WebMessageFormat.Json)]
Employee GetEmpDetails(string emp);
and my input json object will be "{'id':1,'name':'test',....}
Is there any alternative way of achieving this issue.
Thanks
It is possible to send list of items with GET, it's just that out of the box only primitive values are supported. String values work just fine, but if you want to pass a complex object, you need to create a custom QueryStringConverter. The post at http://blogs.msdn.com/b/carlosfigueira/archive/2011/08/09/wcf-extensibility-querystringconverter.aspx explains how this can be done.
If you make your service RESTful you will most probably use HTTP PUT for Add method and HTTP POST for Update method. It is absolutely ok to pass object to these methods because objet will be part of HTTP request's body, not part of URI. URI is important for HTTP GET requests. HTTP GET requests should be only for data retrieval not for data modification.
You are mixing up HTTP GET/POST/... requests and REST GET/POST/PUT/DELETE/...
When you wanna request something RESTfully - you do a GET request. In your case I think it should look like
employee/{id}
or
employee/{name}
Please also note that usage of lowercase in the URI is preferable.
If you need multiple GET criteria, I think it could look like:
employee/id/{id}/name/{name}