How to use globals when the type of variable is int

I created global to use in body but the value of global is int type
How can I put my created global in body when it’s not string?

{
	"image": {
		**"id": {{comment photo id}}**, 
		 "url": "{{comment_photo_url}}",
		"width": 2992,
        "height": 3992,
		"type": "photo"
	}
}

The marked id with bold is int value, and when I put the name of my global in quotes like this β€œ{{comment photo id}}” it gaves me error.
How can I correctly put this {{comment photo id}} in body ?
I attach screenshot as well.
Thank you in advance

All the variables are saved as a string so that might be why it’s happening.

You could add something to the Pre-request Scripts to change the type.

This might work as a workaround solution:

pm.globals.set("id_value" , parseInt(pm.globals.get("comment photo id")) )

Then in the POST body, reference it by using the {{id_value}} variable.

1 Like

Another options would be to store the entire object in a global variable and this will retain the type of all properties.

1 Like