cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Cloud SDK add custom headers to executeHttpRequest

monokizsolt7
Participant

Hello,

How can I add custom headers to the executeHttpRequest call?

This does not work, my custom headers are removed:

await executeHttpRequest({ destinationName: "my_dest" }, {
            method: 'GET',
            url: '/url',
            headers: {
                "my-custom-header": 'test'
            }
        })

I am using: "@sap-cloud-sdk/http-client": "^2.1.0"

Thanks, Zsolti

View Entire Topic

Hey Zsolt,

thank you for reaching out to us, this particular use case isn't very well documented and will be added to the docs in the future.

Instead of directly writing your header into the header field, write it like this:

headers: {
  custom: {
    authorization: 'custom-auth-header',
    'content-type': 'application/json',
    accept: 'application/json'
  }
}
monokizsolt7
Participant
0 Kudos

Perfect, thanks!