restclient.el icon indicating copy to clipboard operation
restclient.el copied to clipboard

Escaping seems to lead to incorrect syntax

Open lake-effect opened this issue 4 years ago • 5 comments

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

lake-effect avatar Mar 09 '20 17:03 lake-effect

Drop the quotes, no need for them

pashky avatar Mar 09 '20 17:03 pashky

Which ones?

lake-effect avatar Mar 09 '20 17:03 lake-effect

in here :url-stem = "http://secret-url.com/"

pashky avatar Mar 09 '20 17:03 pashky

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

lake-effect avatar Mar 09 '20 17:03 lake-effect

Any news?

failable avatar Oct 04 '23 14:10 failable