POST command / Rest service

0
Hello everyone! I am trying, unsuccessfully, to find an example of how to run the POST command on the REST service. Can someone help me please? Thank you in advance for your help.  
asked
2 answers
3

I assume you’ve found the how-to guide for making a GET call: https://docs.mendix.com/howto/integration/consume-a-rest-service#5-calling-the-rest-service-in-a-microflow

A GET and a POST are very similar. The one difference is that a POST has a request body, which is often sent as JSON when used in a REST service. Here’s a page explaining how the two methods are different:

https://www.w3schools.com/tags/ref_httpmethods.asp

In Mendix, this means the one functional difference between making a GET and a POST call is that you need to build the JSON body. When you choose POST in the Call REST Service activity, the Request tab will have settings that allow you to decide how to build the body of the request. The most common way is just the inverse of how you read the response from the service.

When reading the response to a service, you do the following (as shown in the guide):

  • Create a JSON Structure in your project that represents and example response from the service
  • Create an import mapping for that JSON structure
  • Use the import mapping in the Response tab of the REST Call activity
  • The mapping takes JSON and turns it into Mendix objects for you to use in your microflow

Creating the request for a service is the inverse:

  • Create a JSON Structure in your project that represents and example request to the service
  • Create an export mapping for that JSON structure
  • Use the export mapping in the Request tab of the REST Call activity
  • The mapping takes Mendix objects and turns them into JSON for you to send to the service
answered
1

Did you see this learning path: https://gettingstarted.mendixcloud.com/link/path/33/Create-a-REST-API-(Micro-Learning)-

Regards,

Ronald

 

answered