cancel
Showing results for 
Search instead for 
Did you mean: 

Re: CAP - srv.send with headers

03-14-2024 10:47 AM
nicorunge Participant
1518 views 0 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hi CAP Experts,

following the docs here, it should be possible to provide a header parameter using srv.send:

 

await srv.send({ query: SELECT.from('Books'), headers: { some: 'header' } })

 

In my tests, I was not able to receive this provided header parameter in my Books handler. I'm accessing the headers this way: req.http.req.headers

I've created a little demo project to reproduce this behavior: https://github.com/nocin/cap_send_headers
Find my test queries in test/header.http

Do I misunderstand the docs or can someone give a hint, what I'm doing wrong?

Thanks!
Nico

 

0 Likes
View Entire Topic
nicorunge
Participant
0 Likes

As always, reading carefully helps. The headers are transferred to the CAP request object and not to the expressJS request object.

The passed header is therefore in req.headers and not in req.http.req.headers.