It’s not about the spaces. But none of the above “escape” the nested double-quotes.
The JSON message you want to send to the server is:
{"dev_id":"plug1-mcf88","port":1,"payload_raw":"AQE="}
This is the very same as:
{"dev_id": "plug1-mcf88", "port": 1, "payload_raw": "AQE="}
…or even:
{
"dev_id": "plug1-mcf88",
"port": 1,
"payload_raw": "AQE="
}
So, the JSON message you want to send includes double-quotes around the keys (such as "dev_id"
) and around text values (such as "plug1-mcf88"
), but not around numbers (such as port number 1
). This way, computers know where a text value starts and where it ends. Without that, it would not know what to do with the whitespace around the values, like in the 2nd and 3rd examples.
The above should work with Postman just fine.
Next, on the Windows curl.exe
command line, you specify the data you want to send using:
--data "your data here"
On a Mac or on Linux, you could also use single-quotes:
--data 'your data here'
But on Windows, the parameter’s value needs to be surrounded by double-qoutes. However, the JSON data already includes double-quotes itself. Now, if you’d erroneously use:
--data "{"dev_id": "plug1-mcf88", "port": 1, "payload_raw": "AQE="}"
…then Windows cannot tell where the keys and values start and end; it doesn’t even know that the value continues after seeing "{"
. To avoid that, you’ll need to escape the double-quotes in the parameter value:
--data "{\"dev_id\": \"plug1-mcf88\", \"port\": 1, \"payload_raw\": "\AQE=\"}"
Also, again, please see How do I format my forum post? [HowTo]