Day 01 - Test error finding Collection item

There was an error in evaluating the test script: TypeError: Cannot read properties of undefined (reading ‘item’)

I can’t find out the solution. Can someone help?

Hey @azhaanmd :wave:

Welcome to the Postman Community :postman:

This usually suggests that you might have named the request or some other element in the Collection incorrectly or not as per the documentation.

Which actual test is failing?

Can you share the full Public Workspace URL, please. It going to be easier to check that a cropped static image of the solution tests.

Sure,
https://www.postman.com/azhaanmd/workspace/azhaan-15-days-of-postman

“submit collection” file contains the Script

What’s the response code that’s coming back from the server?

Have you created your Postman API key and added to the Postman Vault?

I am getting 401 Unauthorized. Yes, I have added Postman API Key in the Vault. But, still getting the error.

Do I need to add any Auth Type in Authorization Section?

No, if you have added the API correctly in the Postman Vault, with the name mentioned in the documentation - this should resolve the variable referenced in the headers of the request.

What do you see when you hover over the ’{{vault:postman_api_key}}’ variable in the request header?

It shows the exact key, which is referring to the vault key.
The scope says “Vault”.

Do I need to add any Auth Type?
image

No, you don’t need to add anything to that. If you do place anything in there it’s going to override what is currently in the request headers:

The Collection comes preloaded with the x-api-key header with the {{vault:postman_api_key}} variable.

All you need to do is create a postman_api_key variable in your Postman Vault.


I can see that you have hardcorded an API Key in the Auth Helper, please use variables, if you’re adding that to a Collection. Delete that value from your request and also delete/recreate the API Key.

I have removed the keys, I have added my API key in the vault, but still getting the same error. :frowning:

I know it’s getting tiring. But, I have followed every step described. But still not working. I don’t know why. :frowning:

If you’re still getting a 401 Status Code, it’s related to the API Key.

Is it still valid? Have you tried creating a different one and trying again?

If you navigate to https://go.postman.co/settings/me/api-keys can you see if the API has ever been used?

It is valid and not used yet. I have tried creating new keys.
image

I’m at a disadvantage here as I cannot see exactly what you’re doing and what you have tried.

I forked your Collection and using my own Postman API Key, I sent the request (My collection_uid is different because it’s a Fork) and received a valid response:

I’m not sure if you’re using the Web or App platform here - Ensure that you’re using the latest version of the platform and the Postman Agent, if you’re using the web platform.

You could try the good old logout and login again, making sure that you’re saving your all changes before doing that.

If you send a request to:

https://api.getpostman.com/me

Include the {{vault:postman_api_key}} in the request header:

Does that return your user information?

Hi Danny
I also encountered the same issue as Azhaan. I’m using WEB platform. I tried logout and login again.
I’m sure that I have added the API correctly in Postman Vault with ‘postman_api_key’ as the key name. And the headers of the request show ‘{{vault:postman_api_key}}’ matches the vault.

And the collection ID is correct

But I still got ‘401 Unauthorized’ error.

Thank you.

I also got ‘401Unauthorized’ error when I sent a request to: https://api.getpostman.com/me

Thank you Danny.
I installed Desktop Agent. I didn’t change anything but it works for me now, got ‘Status 200 OK’.
So there is an issue with Browser Agent. Hope your team will solve this issue soon.
Have a good day!

When using the Web platform, the Postman Vault variables can only be resolved when using either the Browser Agent or the Desktop Agent.

If you have never installed the Desktop Agent, the Web platform will auto select the Cloud Agent which doesn’t resolve the variables.

When using the Cloud Agent you would have seen a banner displayed in the response section stating the selected agent cannot be used with the Postman Vault.

As this isn’t included in the challenge documentation (that’s my bad) I will update this to reflect that behaviour.

Yeah you’re right. Cloud Agent was auto-selected when using the Web platform. It worked when I changed to Desktop Agent.
Thank you!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.