View and Edit Raw Request before sending

How do I View, and maybe edit, the Raw request headers before sending the request?
Why do I want to do this? I’m creating a few collections that use a single OAuth2 authentication token yet the server (not ours) is replacing Bearer with a non-standard tag. So I need to be able to edit to the request to change this in the Collection.

I notice that I can see the code of the request in a wide range of formats yet it isn’t including headers and values from the parent collection.

I’m use to working with Curl and HTTPie so writing HTTP requests is really not a problem for me. I just need to do what I use to do with these tools using Postman.

1 Like

Hey @Nona2

Welcome to the Postman community!! :rocket:

This is similar to a previous question asked on a different thread - If you take a look through that you will hopefully get the details you need.

You can find a little more information about the syntax to use in the Pre-request Scripts here:

https://learning.getpostman.com/docs/postman/scripts/postman_sandbox_api_reference/#pmrequest

Thanks Danny,

I’ve tried this and the seems to be working for my basic ping test yet it still doesn’t show the inserted headers in a Raw request or the Code view, even after running it. Nor are the headers shown in the Temporary Headers tab.
This is what I added. First to the Collection then moved to request itself.

pm.request.headers.add({key: 'Authorization', value: 'SWSS xxxxxxxxxxxxxxxx' }) 
pm.request.headers.remove('Postman-Token')
pm.request.headers.remove('Cache-Control')

I noticed that it didn’t show the Postman-Token or Cache-Control headers as removed. I’ll check if they are with Wireshark later though wish this wasn’t necessary.

Seems to be coming through for me:

I’ve opened the Postman Console to show the Authorization Header being sent with the Request.

I wouldn’t expect to see the script changes in the generated code snippet, as that wouldn’t pick up the changes from the Pre-request Script and Tests sandbox environment.

To remove the Postman-Token and Cache-Control headers, you could just do this globally, from the General Settings.

1 Like

Thanks again Danny much appreciated.

1 Like