cancel
Showing results for 
Search instead for 
Did you mean: 

Stream with CAP Node JS

08-03-2025 8:13 PM
mouradche Explorer
407 views 0 comments
0 Likes
Subscribe

Hello,
I've implemented a very simplistic CAP service that sends a request to a SAP S4 backend system to retrieve a file as a stream ( .../$value)

This a simplified version of my code in the request handler function :

const results = await _sendAxiosHttpRequest(
            {
                method: "GET",
                url: "<service_path>/$value",
                headers: oHeaders,
                responseType: "stream",
                maxContentLength: Infinity,
                maxBodyLength: Infinity
            },
            <my_destination>);
    
 return [{ value: results.data,
           $mediaContentType: results.headers["content-type"],
           $mediaContentDispositionType: results.headers["content-disposition"] }];            

As you can see, i send the request using Axios and in debug mode I checked that this request to the S/4 backend is successful.
results.data is an object of type IncomingMessage (which is a readable stream)
The problem is that the response generated by the CAP service contains nothing. It returns an empty response. 
Even the headers "content-type" and "content-disposition" are not set.

Do you have any Idea, why it's not working ?

Thank you for your help 🙂 

0 Likes

Accepted Solutions (0)

Answers (0)