need for sending data in JSON format

Viewed 28

I need to change this urlencoded code to JSON:

Query = "X=1234&Y=1234&Z=ZZ&ZZZ=12345&ZZZZ=12345"

I wrote this code, but I have a problem with Z parameter, I've received API response that 'Z is required'.

Query = "{""X"":""1234"", ""Y"":""1234"", ""Z"": {""ZZ"": {""ZZZ"":""12345"", ""ZZZZ"": ""12345""} } }"

Any help will be appreciated, thanks!

1 Answers

The parameters are separated by "&" so z = zz. Not sure why you have a nested structure.

X = 1234
Y = 1234
Z = ZZ
ZZZ = 12345
ZZZZ = 12345

Would be:

Query = "{""X"":""1234"", ""Y"":""1234"", ""Z"": ""ZZ"", ""ZZZ"":""12345"", ""ZZZZ"": ""12345""}"

Though, do you need to quote the numbers?

{"X":1234 , "Y": 1234, "Z": "ZZ", "ZZZ": 12345, "ZZZZ": 12345}

If you are sending this via VBA you typically want the original

"X=1234&Y=1234&Z=ZZ&ZZZ=12345&ZZZZ=12345"
Related