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?
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
Welcome to the Postman Community
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?
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.
I know itâs getting tiring. But, I have followed every step described. But still not working. I donât know why.
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.
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!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.