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

CSRF token validation failed

0 Likes
4,951

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;
}

View Entire Topic
former_member696122
Discoverer
0 Likes

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

0 Likes

Hi Srinivas,

I am using the API mentioned in below screenshot to fetch the token value.

Regards,

Varun Vichare.