Setting Ocp-Apim-Subscription-Key in GraphQL client interface

Should it be possible to set the Ocp-Apim-Subscription-Key header in a Before query script in the GraphQL client interface?

The short script below works fine as a pre-request script in a GraphQL query in an HTTP request, but the same code in a Before query script in the GraphQL client interface produces a 401 Unauthorized: Access denied due to missing subscription key.

Manually adding an Ocp-Apim-Subscription-Key header with a string literal value works fine (in the GraphQL client interface), but then doesn’t allow for easy switching between environments (where the key differs between environments).

Thanks for any pointers!

pm.request.headers.add({
    key: "Ocp-Apim-Subscription-Key",
    value: pm.environment.get("ocpApimSubscriptionKey")
});

When you manually add the header, you can just set the value to the environment variable.

{{ocpApimSubscriptionKey}}

Yes, of course you can… :man_facepalming:

Thank you, Mike! :folded_hands: