cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing response headers from remote service calls in CAP

carlonnheim
Participant
920

Hi,

I have a scenario where I need to access the remote service response headers after having made a call like so

const svc = await cds.connect.to('someservice')

let results = svc.tx(req).send(somequery);
// Here, results contains the parsed response payload, but I cannot find the response headers

What is the appropriate way to do this? I have tried constructing a cds.Request first and then emitting it, but I cannot find the headers anywhere in the request object after the call completes either.

Thanks!

//Carl

View Entire Topic
mantri_sagar
Explorer

You can use SAP Cloud SDK to get raw response for your request and then parse it as per you needs.
https://sap.github.io/cloud-sdk/docs/js/features/odata/execute-request#getting-the-raw-response-and-... 

LucasMagriniRigo
Explorer
0 Kudos

I had to use this to get the CSRF token when calling an S/4HANA Cloud API.

More details of my journey in here: https://stackoverflow.com/questions/40788905/csrf-token-validation-failed-in-nodejs-while-posting-da...