579195 (9) [Avatar] Offline
#1
Hi,

Page 189/214 of 346 . I tried below allowing the problem of copying from the book and the windows parse problem

curl -i -H "Content-Type: application/json" \ -H "Accept: application/json" \ -X PUT 'http://localhost:8484/pi/actuators/leds/1' \ d '{"value":true}'

I got :
curlsmilie6) could not resolve host:\
curlsmilie6) could not resolve host:\
curlsmilie1) protocol "http" not supported or disable in libcurl
curlsmilie6) could not resolve host: d
curlsmilie6) could not resolve host: 't'


I then took out the single quote part in the http address part where it says 'http://localhost:8484/pi/actuators/leds/1' and got below :

curlsmilie6) could not resolve host:\
curlsmilie6) could not resolve host:\
http/1.1 200 OK and the access and content , connection keep-alive attributes then below

{"name":"LED 1" ,"gpio":4}curl: (6) Could not resolve host: \
curlsmilie6) could not resolve host: d
curlsmilie3) Port number ended with 't'

It seem this time it is more a syntax error this time but I cannot work out where ...

pls help.
domguinard (69) [Avatar] Offline
#2
Hi,

The issue with Windows are not really the quotes but the multiline support. Basically Windows does not like multiline commands for cURL which are separated by '/' (see https://stackoverflow.com/questions/24556064/curl-for-windows-how-can-i-send-multiple-line-command-in-a-console)

Try single line commands instead:

curl -i -H "Content-Type: application/json" -H "Accept: application/json" -X PUT 'http://localhost:8484/pi/actuators/leds/1' -d '{"value":true}' 


With or without the single quotes but without the '/' and as a single line.

Does that work for you?
579195 (9) [Avatar] Offline
#3
Hi ,

I tried as a single line

curl -i -H "Content-Type: application/json" -H "Accept: application/json" -X PUT 'http://localhost:8484/pi/actuators/leds/1' -d '{"value":true}'

and it returned :

curl: 1 Protocol "'http" not supported or disabled in libcurl
domguinard (69) [Avatar] Offline
#4
I think not only the single line is a problem for Windows but also the single quotes around the URL, can you try:

curl -i -H "Content-Type: application/json" -H "Accept: application/json" -X PUT http://localhost:8484/pi/actuators/leds/1 -d '{"value":true}'

Cheers,

Dom
579195 (9) [Avatar] Offline
#5
I managed to solve the Windows parse problem with below:

curl -i -H "Content-Type: application/json" -H "Accept: application/json" -X PUT http://localhost:8484/pi/actuators/leds/1 -d "{\"value\":\"true\"}"