AssertionError: expected undefined to deeply equal +0

When running the below script -

var jsonData=pm.response.json();
pm.expect(jsonData.id).to.eql(pm.environment.get("userid_env"));

I am getting the below error.

test the values of json fields | AssertionError: expected undefined to deeply equal +0

please help on this

Hey @orbital-module-ast26 :wave:

Welcome to the Postman Community! :postman:

What’s the response body of that request? This jsonData.id is undefined is that in the response body?

Do you have the environment file selected? What is the value of pm.environment.get("userid_env")?

Using the Postman Console will help you here and show what data is returned in the jsonData variable, from there you can see if the reference to the id is correct.

Thank you for the quick reply. I am new to the postman.

I am getting the below data in the response body

{“type”:“RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content Found”,“status”:404,“traceId”:“00-5b5e100540cacf44b93eaad4e329c72f-1f3a219d4b05a141-00”}

It would appear that you are getting a 404 not found status code for your response, so that is the first issue to resolve.

You need to check your request to confirm that you are sending the correct details.

No one here can help you with that unless you post details of the request, plus details on the API specification to ensure correctness.

If you are new to Postman, then I would suggest a visit to the Learning Centre.

Overview | Postman Learning Center

Including the Postman Training links under “Resources”.

image

I would recommend the “Galaxy APIs 101” course first as it gets you used to the application features.

Then the “Galaxy Testing and Automation” course which teaches you how to assert the responses. It includes verifying status codes.

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