The response id is 9223372036854250224 but when I use console.log(jsonData.id); it is 9223372036854250000

This is the response
{
“id”: 9223372036854250224,
“category”: {
“id”: 2,
“name”: “Cats”
},
“name”: “Tom”,
“photoUrls”: ,
“tags”: ,
“status”: “available”
}

When I run this scripts

var jsonData = pm.response.json();

console.log(jsonData.id);

The value in the console is
9223372036854250000

9223372036854250224 - The response value
9223372036854250000 - console value

What I’m doing wrong?

Hi @m40opud1

Reproduced the same output on my machine, looks like it’s a bug, I have raised a ticket on GitHub.

Have been informed that this is JavaScript related not Postman related;

Hope this helps.

Thank you for the quick response James Wadley! Yes, will try to do it, but I’m not sure what exactly is meant by that, if the value is the Int in the API, how I handled it as a string…

  1. I have a string responseBody
  2. I need to access Id value 9223372036854245504
  3. for that I need to represent responseBody as JSON
    and at that stage, it is already broken… I wonder how vdespa expected to handle this, maybe I miss something…

As soon as you apply JSON.parse to this object, your data will be corrupted.

You have two options:

  1. Change the API or talk with the API developer to convert that number into a string. Some APIs provide a separate property as a string.

  2. Develop a regex to put quotes around the long number before parsing it.

1 Like

Thank you for the answer mister Valentin!
Will try the second option,
Glad to receive the answer from the Guru, you inspired me to develop the ‘API testing course for testers’ and I faced this obstacle during developing it)
Thank you for the help, wish you all the best!

I would be very interested in hearing more about the “API testing course for testers”!!

The free version of the course is already available on Udemy.
Mostly it is about manual testing of the API’s
I started to work on it in February 2022 but… I’m from Ukraine and in Ukraine so it was very very bad timing, horrible timing… you know, it’s not an easy task to work on the course during such huge amount of s… “stress” lets call it “stress”…)))) (((( - (brackets mean to show the mixed emotions)

You can get familiar with the course via link

If everything will be… lets say “fine”. I will be able to finish the full much much more advanced version of the course till November, but… I don’t know… hopefully I will ))))(((( -mixed emotions again)))

I use Postman for testing in my course, And I love the Postman, I really do) Want to show testers that if you use the Postman features properly, API testing becomes easy to do. But it is the second part of the course, I’m busy on it now.

1 Like

Should definitely share in the community showcase section!

Got it, thank you! Will do once the full version of the course will be available I will create a free coupon for the Postman community and share the full course!

1 Like