Search code examples
ibm-mobilefirstmobilefirst-server

How to send headers received from a rest service in MFP Adapter to App


I have an app which calls a adapter and which has a procedure that connects to rest service to fetch me the required data and I am sending the data back to app.

The request body comes fine to app. But how do I send headers that I receive from rest services to app .i.e I want my adapter to send the headers that it receive from rest service to my app.

I am using the following adapter code.

function getFeed(tag,json) {

var input = {
    method : 'post',
    returnedContentType : 'json',
    path : 'myservice',
    headers : {'head1': 'value'},
    body: {
                contentType: 'application/json' ,
                content: json
                    },

};


return WL.Server.invokeHttp(input);

}


Solution

  • The response JSON that reaches the client (the result of WL.Server.invokeHttp(input) ), contains a key "responseHeaders".

    This responseHeaders is a relay of the headers that were received from the backend.