Calling a REST API with dynamic body parameters

0
Hello everyone, I use a REST API to retrieve data from the Opcenter backend. In a microflow I have placed the tool "Send REST request (beta)", the method of the referenced REST request is POST and in the body a JSON with the query itself and a parameter is transmitted. The result is a list and it works so far.     Here is the JSON that is sent in the body:     Now I want to be able to change the value of the parameter "P1" dynamically. There should be an input field above the display grid in which any string can be entered and this string should then be transmitted to the REST API as the value in the "P1" parameter.   I have already prepared an export mapping, but I don't know how and where to use it:     The JSON structure from Export mapping is also stored in the domain model:     Now my questions: How do I use the export mapping in the REST API call to query data with dynamic P1 values? Can I map the input value from the input field to the "Value" node (green bordered) to change the search parameter P1 and this is then automatically used in the export mapping?      Thanks in advance for your help.      
asked
3 answers
4

Hello Uwe, there's also another, simpler way to accomplish this in the new "Send REST request (beta)".

If you put squiggly brackets around text, that turns it into a parameter.

See the example below on how to make it work:

 

Step 1: Set up the body like this

image.png

 

Step 2) Set the test value in the Parameters tab

 image.png

 

Step 3) Provide your runtime value in the microflow action

image.png

answered
0

Hi Uwe Friedrich,

What you have created so far is correct, to get the desired Json String, Use Export to Mapping Activity before the rest call and pass the Export mapping the Root object to the Export to Mapping activity.

In your microflows, you have to create the necessary objects present in the Export Mapping and associate it. 

In your case Create Query object ( Root Object ) , Create parameters object and associate it with Root object, create parameter object and set the values, either hardcode or pass it via the microflow parameters. 

 

image.png

For your Reference Hope this helps

answered
0

Thanks for your answer, I have one more question:

What type of tool/item or what ever I have to use to "Create Query", "Create Parameter" and so on? When I use the search, which opens when I press the "+" sign I cannot find "Create Query" or similar:

Where I have to place this things - here?

image.png

 

Thanks for your help.

answered