Hello Postman Community,
I am currently taking the 15-day challenge and I have encountered an error on day 4. I have attached some screenshots that show the error I am facing. The body of the error message is:
“message”: “Invalid API Key. Every request requires a valid API Key to be sent.”
In addition, I received this test result:
“There was an error in evaluating the test script: TypeError: Cannot read properties of undefined (reading ‘item’)”
I have tried to resolve this issue by adding the API key in the submit and making the authorization folder the parent. However, this did not work. I also tried making the collection the parent, as shown in the attached screenshot, but still encountered the same error.
I am hoping that someone in the community can help me understand what I am doing wrong and provide guidance on how to resolve this issue.
Thank you for your help in advance!
collection link :Postman
The test is failing as the response is not returning the collection JSON as it should.
Therefore the “item” element in a normal response does not exist.
It’s failing to return the response, because of the api key.
It’s telling you the reason. “This is a duplicate header”.
This challenge, has just shown you three separate ways to authenticate.
The headers tab, a query parameter or an auth helper.
But the final step tells you to remove all of that and then use the auth helper method at the collection level. (This should be at the Day 04: level, not the authorization folder).
Add collection-level auth : Since all of the requests in this collection require the same authorization method, let’s add a collection-level authorization helper. For each of these three requests, delete the added header, delete the params, and update the Auth type to
Inherit auth from parent . The parent of this request is the folder or collection that contains these requests. Select the collection
Authorization , and add the
API key auth helper under the
Authorization tab like you did in the previous step. Send at least one of the requests to make sure you receive a 200 status code, and then save all of your changes.
The submit collection request should be set to “inherit from parent” and you should not need to manually add the x-api-key as a header to the submit request as it will be coming from the auth helper set at the top level.
The requests in the authorization folder will also use same API key, so ensure they are also working.