Getting the response body as 404 not found while trying to Fetch the data by using id

“java.lang.NumberFormatException: For input string: “obj.id”” is the error message I’m receiving when I try to retrieve the data using the id (which I set as environment vairable i.e. petid) in the request url.

I’ve included a screenshot of the POST body and scripts along with the get request for reference; kindly assist me in resolving this. Many thanks in advance.

Hey @flight-geoscientist2 :wave:

Welcome to the Postman Community! :postman:

In line 2, you’re setting that variable to be the string obj.id rather than the value of the it. You need to remove the quotes.

That’s why it’s mentioning that in this response:

The request payload is JSON so I’m not sure why you’re using pm.request.xml2Json here. What does that even log? Can you use console.log(obj) under that line to see the output of the variable?

Thanks @danny-dainton… i have tried that as well

You’re not accessing the request payload correctly there.

You would need something like this to access the JSON:

console.log(JSON.parse(pm.request.body.raw).id)