on 11-08-2021 5:44 AM
Hello Experts,
I am building an interface to post an attachment to S/4HANA using API_CV_ATTACHMENT_SRV entity. I am passing all the required headers to this entity but still I am getting CSRF token validation failed error. Please find below screenshot for your reference. Request you to please suggest a workaround for the stated issue.
Below groovy script used to pass Cookie header
import com.sap.gateway.ip.core.customdev.util.Message;
import groovy.xml.*;
import java.io.*;
def Message processData(Message message)
{
def headers = message.getHeaders();
def cookie = headers.get("set-cookie");
message.setHeader("Cookie", cookie);
return message;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Varun,
did you manage to solve the problem?
I am having the same issue using the HTTP channel to update data in S/4HANA.
Unfortunately I cannot use the oData receiver adapter because the service I am using does not support navigation.
Regards,
John
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Varun,
Are you passing token value to Header? I see you are passing the text vale 'x-csrf-token' as Token value. But ideally you need to get the Token value from S4 and pass the same during your call.
Thanks
Srini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi varun_vichare_cpi,
Could you share the details of the error.
Could you enable trace and check if the x-csrf-token value is set.
In addition could you check if you are able to make calls using POSTMAN.
thanks and regards,
Praveen T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
PFB screenshot for error details and attached file for set headers. I am able to make calls to the API successfully though postman.
messagelog-attachment-api-attachment-1-http-receiv.txt
Regards,
Varun Vichare.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.