WCF Data Services - Custom POST method
By : J.S.
Date : March 29 2020, 07:55 AM
|
PUT and POST getting 405 Method Not Allowed Error for Restful Web Services
By : August Hummert
Date : March 29 2020, 07:55 AM
this one helps. Well, apparently I had to change my PUT calling function updateUser. I removed the @Consumes, the @RequestMapping and also added a @ResponseBody to the function. So my method looked like this: code :
@RequestMapping(value="/{id}",method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public void updateUser(@PathVariable int id, @RequestBody User temp){
Set<User> set1= obj2.getUsers();
for(User a:set1)
{
if(id==a.getId())
{
set1.remove(a);
a.setId(temp.getId());
a.setName(temp.getName());
set1.add(a);
}
}
Userlist obj3=new Userlist(set1);
obj2=obj3;
}
|
How to pass parameter(s) to a WCF post method (a restful services)
By : Rajesh
Date : March 29 2020, 07:55 AM
will be helpful for those in need Finally after many trials and many things, I got the working solution. Here I am posting what I did for the POST method to work. code :
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "AddOrders", RequestFormat =
WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,BodyStyle =
MessageBodyStyle.Bare)]
int AddOrders(RequestData orderRequestData);
WebClient WC = new WebClient();
WC.Headers.Add("Content-Type", "application/json");
WC.Encoding = Encoding.UTF8;
MemoryStream MS = new MemoryStream();
DataContractJsonSerializer JSrz = new
DataContractJsonSerializer(typeof(RequestData));
JSrz.WriteObject(MS, order);
string data = Encoding.UTF8.GetString(MS.ToArray(), 0, (int)MS.Length);
byte[] res1 =
WC.UploadData("http://localhost/EMCService/Service2.svc/AddOrders", "POST",MS.ToArray());
MS = new MemoryStream(res1);
JSrz = new DataContractJsonSerializer(typeof(int));
int result = (int)JSrz.ReadObject(MS);
|
Can you POST in a GET Method in Rest services?
By : user110236
Date : March 29 2020, 07:55 AM
this will help I don't think you can have multiple body parameters (or if you can, it's certainly not a good practice!). Check to see if the ContextName parameter is a different type of parameter such as a query or path parameter (called template parameter in SoapUI). Here is some info about different types of REST parameters in SoapUI: http://www.soapui.org/rest-testing/understanding-rest-parameters.htmlI'm not sure what you mean in your second question. Perhaps you want to write a Test Case with multiple Test Steps (a GET and a POST)? Check out this link: http://www.soapui.org/functional-testing/structuring-and-running-tests.html Also look at the other sections under Functional Testing to learn how to control the flow of test steps.
|
Spring MVC 3.1 REST services post method return 415
By : Arnaldo Rodriguez
Date : March 29 2020, 07:55 AM
Hope that helps Well, "UNSUPPORTED_MEDIA_TYPE" should be a hint. Your curl command is actually sending:
|