cancel
Showing results for 
Search instead for 
Did you mean: 

Passing form-data to external API through script task in SAP Cloud Platform workflow

PriyankaSingh04
Explorer
0 Kudos

Hello All,

I have a requirement to do a HTTP POST request to an external API for fetching the token. This API is accepting parameters only as form-data(see attached image). If i try to convert it to JSON or run in raw it gives status 404.

I need to trigger this API in the SAP cloud workflow using a service task. What should be the code to pass this form data in the workflow script task context? I tried possible combination like passing it as JSON, sending it as x-www-form-urlcoded format but the API is returning bad request and not able to recognize it as form-data.

Any pointers in this regard will be appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

tobias_breyer
Contributor
0 Kudos

Hi Priyanka,

Cloud Platform Workflow has OAuth support so there should rarely be the need to pass authorization data yourself through the Authorization header.

So I would recommend to check whether standard authentication mechanisms can be used where CP Workflow manages the authentication via the destination settings. In contrast, putting authorization data into the workflow context opens up security and compliance questions, as the workflow context is not meant as a secure store and is available for being viewed by anybody that has suitable permissions.

Anyway, the previous thread on header support is still valid. Currently only service task bodies are available for transfer of data to the service. Headers are not available.

Regards,

Tobias

PriyankaSingh04
Explorer
0 Kudos

Thank you Tobias.

Answers (1)

Answers (1)

tobias_breyer
Contributor
0 Kudos

Hi P S,

Cloud Platform Workflow only works with clean JSON REST services. We are setting the headers accordingly, i.e. to application/json, and there is no option to send something else than JSON. That's why you probably get Bad Request - the service receives data that it does not expect and cannot handle.

"form-data" are key-value pairs that are not structured according to JSON. They have syntactically no common sub-set, only semantically.

If you have specialized integration requirements like here, you should check out Cloud Platform Integration (CPI). For simple cases, you might be able to implement an intermediate service that converts the data on your own, e. g. using node.js on CP Cloud Foundry environment.

Regards,

Tobias

PriyankaSingh04
Explorer
0 Kudos

Thank you Tobias.

I have one more query in addition to this issue-Can we pass Authorization Bearer token as header in the script context?

I read some thread that mentions it is not supported but do we have any workaround which can be used to pass it into the Service task.

Regards

Priyanka