I'm trying to send a POST request with curl, but I'd like to store the json data in a variable in order to resend it if an error occur. I used this code:
jsonvariable="{"ora" : "value1", "temp" : "value2", "rh" : "value3", "lat" : "value4", "longi" : "value5"}"
curl -X POST -H "Content-Type: application/json" -d '$jsonvariable' http://localhost:8080/updates
but the format after the -d
option is not correct. Can you help me?
this code:
curl -X POST -H "Content-Type: application/json" -d '{"ora" : "value1", "id" : "value2", "temp" : "value3","rh" : "value4", "lat" : "value5", "longi" : "value6"}' http://localhost:8080/updates
gives no errors instead