REST POST using Json

I am using the Rest Services module from the appstore to create a connection with another application. I want to create a person in the other application, by posting a request. The Rest Services module turns my post request's body into some sort of HTML parameterized code. This isn't compatible with the receiving end, because it needs to be json. This is an example of what the Rest Services module puts in the body: It needs to look like this: {"sex":"m","initials":"C. M.","firstname":"Piet","insertion":"van","lastname":"Beek","address":"xxx","zipcode":"xxx","city":"Amsterdam","phone":"","mobile":"xxx","email":"","birthdate":"23-01-1923","birthplace":"Den Haag","nationality":"NL","establishmentId":"37"} How can I achieve this? Is it possible to edit the Java code and encode the body to json in some way? EDIT 9-11-2015 16:19: In response to Anthony: That's a great idea! I have added the header, and it comes up with a different error message: Uncaught exception 'Exception' with message 'Content-type could not be produced: 'application/json, application/json', Use: 'application/json|application/xml' instead' It seems as though there already is a header attached with the value 'application/json'. I have changed the value to 'application/json|application/xml', but this still generates the above error message. Any ideas?
2 answers

The shared microflow contains an action addHeaderToNextRequest with params accept|application/json. Try to change this to Content-type|application/json



Did you try to use the 'request' java action and set the method to POST? I think that is the preferred way to do this. This action is included in the 1.5.0 version of the REST Services module. You can find this Java action in

RestServices -> CONSUME -> request

  • Method: POST
  • URL: the endpoint your resource is located
  • optRequestData: pass your request object here.
  • optResponseData: can be empty
  • sendWithFormEncoding: false