How to add a custom header to the response body

How to add a custom header to the response body in ?

It is necessary to include it in the response header, and not in the response body.

I’ve tried adding a header to Headers and to Pre-req., but these options insert it into the body of the response, not into the response header.

You use the headers tab on the request.

If you must use a pre-request script, then you can target the headers using something similar to the following.

    disabled: false,
        content: "DescriptionTest",
        type: "text/plain"
    key: 'keyName', 
    value: 'keyValue'

Thank you for responding, but this way I also get the transmitted header in the body of the response.

It is not in the response header.

Sorry, I misread your question.

You can’t add a header to the response as its static, and just shows what is returned by the server.

If you want additional headers in the response, then the API would need cater for this.

You cannot manipulate the response. What you can do is parse the response, and potentially add the header to the parsed object.

Can I ask what the use case for this would be?

I make cheat sheets on the most frequently used scripts and tests for my team.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.