SAP Cloud Platform Workflow Service: Invoking an OData API of method type POST – PART 1
In my previous blog, I explained how to call an OData API of method type GET from SAP Cloud Workflow service.
In this blog, we’ll invoke an OData API of type POST. This OData API accepts it’s input as parameters in the URL as opposed to accepting a JSON payload.
- You have the URI to invoke the OData API
- You have the credentials to authenticate the call
I will be using an OData API provided by SuccessFactors to add a comment into an SFSF workflow (not to be mistaken with SAP Cloud Workflow Service). You can refer to the following document for further information (in this case, section 13.6.2 in the below guide):
|OData URI||https://apisalesdemo4.successfactors.com/odata/v2/commentWfRequest?wfRequestId=2124L&comment=’Some nifty comment that makes sense!’|
For the sake of simplicity, I will be reusing the destination created in the previous blog. In case you aren’t familiar with the configuration, please feel free to refer to that section in the blog.
Let’s get to the interesting bits; invoking an OData API of POST type from the Workflow.
As usual, I will be using a rudimentary workflow to demonstrate this process.
Let’s get into the Service Task ‘POST SFSF Content’ and see how we call the OData API.
The steps involved are simple and straightforward.
- Use the appropriate destination (here, the one mentioned above) in the Workflow’s service task
- Provide the path to the OData API
- Append the response from the OData API into the context of the Workflow
The destination is configured as https://apisalesdemo4.successfactors.com/
That leaves us with the path to the OData API as /odata/v2/commentWfRequest?wfRequestId=2124L&comment=’Some nifty comment that makes sense!’?$format=json
Note, the URL is not to be decoded. The structure of the query remains as is, with all the spaces and special characters in the query.
Also observe, the parameter ‘format=json’ ensures that the response is received in JSON format, which can be consumed by the workflow.
|Path||/odata/v2/commentWfRequest?wfRequestId=2124L&comment=’Some nifty comment that makes sense!’?$format=json|
|Path to XSRF Token||Leave this blank|
|Request Variable||Leave this blank|
Since we are concentrating on a POST API that does not take a JSON payload, we can leave the ‘Request Variable’ empty.
The ‘Path to XSRF Token’ is also not required since the trust is established through Basic Authentication here.
That’s about it. The response of this call will be added into the process context in the following path – context > sfsf > response
The response will be of type JSON owing to the parameter sent in the path – format=json
When this workflow is executed, an SF workflow corresponding to workflow request Id 2124 will be updated with the comment passed as a parameter. In the SuccessFactors system, this can be observed as below
In the workflow, you will receive the response of this OData API which will look like this:
So, there you go. We now have managed to call a simple OData API of type POST that does not take a JSON payload. In the next part, we’ll call an OData API that requires a JSON Payload. See you there… Cheers