Hello everyone,I have a question related to postman console. For example I have created two environments one is company with variable name Api-Key and other is Partner with variables names Api-Key and Token-Number and I select all these three variables in headers and I use these variables for same url let’s say google.com . So my question is when I send request by selecting the Environment Company and It’ll show me the response but in console, request headers display all the headers which I selected but I want only the header related to the Company Environment and all other headers are automatically hide, how I do it?
@sean.keegan
Hi @moaaz124! Welcome to the Postman community!
If I’m understanding your question correctly, you want certain headers to be hidden automatically based on which environment is chosen? If that is the case, I don’t know if that functionality is possible by default. The request you send will always show the headers in the console.
One thing you can try would be checking to see if a variable exists in the current environment, and if it does, programmatically add a header in the pre-request script tag. Here is a link to this example. I tried my best to emulate the conditions you mentioned in your post, but please let me know if that doesn’t work fo you! You’ll see two environments called Partner and Company, where the Partner environment has an Api-Token and Company doesn’t.
Feel free to fork the collection to try it out on your own!