Question

IFS REST Call in Workflows


Userlevel 2
Badge +4

In Workflows I have the possibility to call an external REST API which works perfectly. But by POST I can insert only one object per call.

Is it possible to create multiple objects with one call?  Background of my question: The performance is quite poor with multiple REST API calls when I want to transfer mass data.

 

 


11 replies

Userlevel 3
Badge +7

Hi Stefan.

I’m afraid that your requirement doesn’t depend on IFS Cloud functionality. You are calling a 3rd party system using the IFS REST delegate. It is the 3rd party API that you are calling the one that should provide you with a way for creating resources in one single call.

 

The way IFS Cloud allows to create multiple records using one single call is standard OData batch mechanism.

Here is the standard documentation:
https://www.odata.org/documentation/odata-version-3-0/batch-processing/

Here is the specific IFS Cloud documentation:
https://docs.ifs.com/techdocs/23r1/040_tailoring/300_extensibility/100_odata_provider/700_batch_requests/

 

But remember, the documentation above is only valid in case you wanted to call IFS Cloud from a 3rd party system. This is not your case; you are calling a 3rd party system from IFS Cloud.

 

I hope you can check the OData batch mechanism with the 3rd party REST API provider and determine if it is possible to create mass data in one single call.

 

Thank you much.

Best regards.
Gonzalo.

 



​​​​​​​

Userlevel 4
Badge +9

Hi,

This would depend on the batching capabilities of the external API you are calling. For example IFS Cloud REST APIs supports batching multiple operations into a single requests. https://docs.ifs.com/techdocs/23r1/040_tailoring/300_extensibility/100_odata_provider/700_batch_requests/

Do you see any limitation in the Workflow designer itself that is limiting the payload to just one object?

Userlevel 2
Badge +4

Hi Rifki,

 

as you can see in my screenshot I am using variables in the body of the REST call. For me it is not clear how I can do a batch transfer. I would like to send a structure like:

 

[
{
"Title": "aaa",
"aoDelegateFrom": "",
}
],
[
{
"Title": "bbb",
"aoDelegateFrom": "",
}
],
...

Best Regards

Stefan

 

Userlevel 4
Badge +9

Hi,

You should be able to type this structure in the request body textbox in the Workflow designer right? I think more importantly what you need to check is whether the external API will accept such a structure and create multiple objects? This will not work unless the external API actually supports it.

Userlevel 3
Badge +7

Hi Stefan.

As we mentioned before, all depends on the API you are working with. Try to check their documentation to find out whether is possible or not to send that can of payload.

 

Usually a proper REST design would allow only one record to be created using POST action. In the same way you can only PATCH/PUT on a single record. Same applies to DELETE.

 

OData standard implements the batch concept. You can send multiple POSTs inside a single payload. Here is an example how it would look like:

 

 

Check if your REST API provider support this mechanism or similar.

 

Best regards.

Gonzalo.

 

Userlevel 2
Badge +4

Hi Rifki,

yes, the external system will accept such a structure. But I would need some kind of loop to create the structure in the message body based on the result set which I get in my workflow.

The workflow looks like this:

At the moment I have one webservice call for each iteration of the loop.

In order to do only one webservice call I would need to move the marked box outside of the person loop but then I am not aware how to handle the result set in the message body.

 

/Stefan

 

Userlevel 2
Badge +4

@Gonzalo 

What you are writing is absolutely correct and I am aware of it. But my issue is, I am not able to create a request body in BPA with multiple records in it. It seems one REST-Call is always one record, otherwise I would need some kind of loop to create dynamically the request body. The amount of records is not static in my case and depends on the result set of the previous query.

Hope now it is more clear.

 

Userlevel 3
Badge +7

Hi Stefan.

 

Yes, the call to the external service should be out of the loop iteration. You would use the loop only to compose the payload. Then out of the loop, you would make the call using the previously calculated payload content. Isn’t this possible?

Best regards.

Gonzalo.

 

Userlevel 2
Badge +4

@Gonzalo 

Yes, it works. I were not aware that I can just put the variable in the message body and concatenate the string via JavaScript inside the loop.

Userlevel 3
Badge +7

Glad to read it works! Thanks for letting us know.

 

Have a good day.
Best regards.
Gonzalo.

 

Userlevel 4
Badge +9

Hi @FleStefSc 

Appreciate if could mark Gonzalo’s response as the answer to help others easily find a resolution to similar requirements 

Reply