Inquiry: I have an authentication API that provides me with a token. My goal is to use this token automatically in another API, which is in a separate collection, by setting it in a global variable. The response of the authentication API is a token string like this:
I have tried to write a Pre-request script in the collection as follows:
var res = pm.response; pm.environment.set("token", res);
However, when I try to run another API that uses the token variable, I receive a 401 authentication error.
If I replace the token variable manually with the value
hrzehrz3hbgr988BD89dh, the API works properly.
I have the following response :
I don’t understand why I don’t see the response value.
Any help or suggestions would be greatly appreciated.