restclient.el
restclient.el copied to clipboard
Escaping seems to lead to incorrect syntax
I keep getting Unauthorized when I try a request with basic auth in restclient-mode, so I exported it to curl with C-c C-u
, and got a very elaborately escaped command:
Initial curl request:
curl http://user:[email protected]/endpoint -X POST -H 'Content-Type: application/json' -d '["entry"]'
restclient:
:url-stem = "http://secret-url.com/"
:creds := (format "Basic %s" (base64-encode-string (format "%s:%s" "user" "password")))
# Add number to pool
POST :url-stem/endpoint
Content-Type: application/json
Authorization: :creds
[
"entry"
]
Exported curl request:
curl -i -H Authorization\:\ Basic\ dXNlcjpwYXNzd29yZA\=\= -H Content-Type\:\ application/json -XPOST \"http\://secret-url.com/\"/endpoint -d \['
'\ \ \"entry\"'
'\]'
'
Curl of course throws curl: (6) Could not resolve host: "http
Drop the quotes, no need for them
Which ones?
in here :url-stem = "http://secret-url.com/"
Same result:
# -*- mode: restclient ~*~
:url-stem = http://secret-url.com/
:user = user
:pw = password
:creds := (format "Basic %s" (base64-encode-string (format "%s:%s" ":user" ":pw")))
# Add number to pool
POST :url-stem/endpoint
Content-Type: application/json
Authorization: :creds
[
"entry"
]
curl -i -H Authorization\:\ Basic\ OnVzZXI6OnB3 -H Content-Type\:\ application/json -XPOST http\://secret-url.com//endpoint -d \['
'\ \ \"entry\"'
'\]'
'
curl: (6) Could not resolve host: secret-url.com
Any news?