Key name in Json contains a space

How do I get the value from a key that has spaces in name like:

“values”: {
“Request Number”: “REQ000000023077”

Want to do:
postman.setGlobalVariable(“REQ_InstanceId”, jsonData.values.Request Number);

I’ve tried with [ , { ,’ , ", and any combination of brackets and quotes e.g. [‘Request Number’] but everything gives an error like Unexpected Token.

Any clues?

The bracket format should work, since it’s standard javascript.

For eg:

let values = { 
	'Request Number': '1234'

console.log(values['Request Number']); // 1234

For your case:

postman.setGlobalVariable(“REQ_InstanceId”, jsonData.values['Request Number']);

I have tried that but unfortunately it yields a Syntax error and in my Postman I can see already when defining the Test that it won’t work.
Please see the attached screendump

1 Like

Hey @psorense. That is because you’re using both . and [ to access the field. Use only the [ or simply copy what @sivcan mentioned above.

What a difference a dot makes :blush:
Thanks and sorry for being an ignorant.