cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP Build Process Automation: Problem with POST Action and CSRF-Token

former_member15145
Discoverer
0 Kudos
8,703

Dear SAP Community,

Lately i am trying to build a workflow with SAP Build Process Automation and Actions.

I configured a standard API (Product) as mentioned in a developer tutorial. The GET request ist working. In the API testenvironment the POST request to the system works and the corresponding entity is created (see screenshot). The destination, ressource path and x-csrf-token path etc. seem fine and the OData-calls are traceable in the backend.

However when I use this POST request in the process step in a workflow the corresponding step fails.

The error for the step says:

Action '<actionid>' failed with the following error: 'Error thrown from action runtime library: Could not fetch X-CSRF token for action <actionname>: Request failed with status code 403'.

I can´t trace or debug more than this because the whole service logic resides in the cloud. The error message says that the error is in the "action runtime library". I dont exactly know which part of the whole process is wrong.

Edit: When I try the POST call with a different token endpoint ( mentioned here in the comments, https://blogs.sap.com/2022/10/31/configuring-x-csrf-using-actions-editor/ )

like this /sap/opu/odata/sap/<servicename>/<actionname>

The test environment still works and in the workflow step the action still fails but the token however is fetched in the backend. The error message in the monitoring feature this time says: Internal error occurred


Best Regards,

Marco

Accepted Solutions (1)

Accepted Solutions (1)

former_member15145
Discoverer

Update:

I found the solution for the problem:

According to a mission in the discovery center, you have to configure the destination with the respective endpoint for the service and use "/" for X-CSRF-Token endpoint and ressource path in the action project. Then the X-CSRF-Token is fetched and submitted in the following POST Call.

The destination settings should look like this:

For example for the standard product (material) API,

http://<destinationhost>:<destinationport>/sap/opu/odata/sap/API_PRODUCT_SRV

with additional properties

  • sap-client: <mandt>
  • sap.applicationdevelopment.actions.enabled : true
  • sap.processautomation.enabled : true

In the action project when using the standard API use "/" for both x-csrf-token endpoint and ressource path.

RaghavaReddy
Explorer
0 Kudos
Hi, I have followed your steps as advised but still no luck with the POST request. Any solution found on this? Please share. Thanks
J123
Discoverer
0 Kudos
It is working in test, but failing in the workflow. Any update on it?
sdeissenboeck
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi, for resource path, I am not allowed to specify "/". How did you overcome this?

Answers (5)

Answers (5)

0 Kudos

Hi

I am facing same issue recently, any solution for this?

shantanusharma
Product and Topic Expert
Product and Topic Expert
0 Kudos

I have exactly the same issue with a POST request using the sales order header API (A2X). Works when I test the action. The API works when I test the API in postman, although there I have to fetch the token via a GET request and add it to the header when I make a POST request.

LUNGILEND
Explorer
0 Kudos

Hi Shantanu,

I am currently getting the same issues

Kinds Regards,

NickvanHeertum
Explorer
0 Kudos
Did you find a solution for this? we experience the same
Archana
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Marco,

There could be multiple reasons for this, and we have to look into your project to identify the issue. Some time the sap-client is not set correctly, or the cloud connector setup could be the problem. Can you please raise a ticket on BPI-PA component and provide the details, we will look into the log traces and suggest you accordingly.

0 Kudos

please provide a cloud connector configuration guide for this requirement.

Archana
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Marcos,

Is this S/4HANA on-premise or cloud API ? How are you testing in Action Project - via destination or manual ?

former_member15145
Discoverer
0 Kudos

Hello Archana Shukla,

1. S/4HANA on-premise

2.I use the test environment of SAP Build Process Automation and the test feature there. The connection to the backend via destination works with the exposed API in the testenvironment (fetch of the token and post method) but it is not working in an instance of a workflow process (token is fetched but the post request is not triggered , confirmed in trace logs).

In general the get method(s) work but the post/put etc. calls dont work in an workflow instance.

Thank you very much for your reply.

ramuknura1395
Explorer
0 Kudos

Hi archana.shukla / mndev96 ,

We are using S4 HANA Public Cloud, We are also facing the same issue.
"Action 'XXXXXXXXXXXXXXXX' failed with the following error: 'Error thrown from action runtime library: Could not fetch X-CSRF token for action 'Invoke action releaseApprovalRequest': Request failed with status code 403'."

Scenario 1:

I tried configured with S4 HANA Cloud destination and added resource path for sales quotation API from standard POST method.
While testing from action project itself it worked. but after published and added into Build Process. I am getting the above error.

Destination : https://xxxxxxxxxx-api.s4hana.cloud.sap

Scenario 2:

I tried configured with S4 HANA Cloud destination particular to that API
https://xxxxxxxxxx-api.s4hana.cloud.sap/sap/opu/odata/sap/API_SALES_QUOTATION_SRV
Added / for both resource and X-CSRF Token. in action project locally it's working. but it's not working via process workflow while approving. same X-CSRF TOken 403 issue.


Please help in this case,

Thanks & Regards,

Arun Kumar -D

pb-bp
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello,

could you please provide the links to the documentation that you are using?

former_member15145
Discoverer
0 Kudos

Hello Paulina Bujnicka,

I used the tutorial provided on youtube by your colleague Archana Shukla, the sap help page (documentary) and the missions on the sap discovery page. I got everything working except the post/put etc. request of an action project in an workflow instance.

It also seems like that many ressources aren´t up to date anymore. For example the menu changed a bit. The setting option is in a different place now (top right) and you have to configure the ressource path and csrf path separately.

Thank you very much for your reply.

pb-bp
Product and Topic Expert
Product and Topic Expert
0 Kudos

mndev96 Please provide us all URLs of the documentation. That way we can check it and update it.