1 test fails since it canât find âapikeyâ any more (pm.expect(response.json().collection.auth.type, âcheck collection authorizationâ).to.equal(âapikeyâ))
The instructions for that day details the following.
Add a collection-level authorization helper to add an API key like x-api-key and {{postman_api_key}} to your request headers.
The key name that goes in the header is always x-api-key. That is what Postman is expecting for authentication. The variable name that you store the key, can be anything you want. However most of the challenges and examples use {{postman_api_key}}
Itâs doesnât appear to be checking the variable name.
Itâs just checking that the auth type is set to API Key.
Which your screenshots appear to show ok.
You could add a line temporarily to console log the auth type in that code block in the Tests tab to see what is actually being returned.
console.log(response.json().collection.auth.type)
The auth type should inherit throughout all of the requests in that collection including the submit request. Just make sure you donât have any of the requests with its own authentication, otherwise it will return an array for the auth type and the test will fail.
response is the correct variable, as itâs the sendRequest which is defining it, not the main response which is being assigned to the variable âresâ right the top of script (where you added your bit of code).
Are you sure that all of the folders and requests within the collection are all set to âinherit from parentâ?
You can also select the request from the GET request in the console log, and look at the response that was retrieved. You should be able to drill down to the auth.type from here. (or use the version that you specifically console log instead). The requests appear to be showing 200 ok, so Iâm assuming that the response should be the collection JSON.
Thank you very much for your help! There was a mistake in my environment variable. I have found it due to console.log. Now tests work fine. I will use logging more often now.