In each of my requests I need to pass a
Ocp-Apim-Subscription-Key header. In this header I provide my subscription key for my API provided by Azure API Management.
Normally I would do this for each request.
What if I need to change the subscription key? I would have to change it in each and every request.
This would become quite tedious for an Api with a lot of operations.
One thing I could do would be to store the
Ocp-Apim-Subscription-Key in an environment variable.
I can assign the environment variable as the value for the
Now if I need to change I can do it in one spot.
When I need to request a new request for a different operation I usually duplicate a previous operation to I don’t have to keep adding the headers for
This does not feel right.
Seems like a lot of duplication.
Be nice if I could just apply global headers to all request within a folder, as opposed to each request.
To do this, click the ellipses next to the folder you want to share headers for contained requests, and select Edit, in my case, I clicked the ellipses next to the Azure folder.
Click the Pre-request Scripts tab.
Paste the following code into the Pre-request scripts.
Note, you can still use the environmental variable we created in the previous step.
For any requests executed in the folder, the headers for
Ocp-Apim-Trace will be added.