pashky / restclient.el

HTTP REST client tool for emacs
1.99k stars 171 forks source link

Escaping seems to lead to incorrect syntax #226

Open lake-effect opened 4 years ago

lake-effect commented 4 years ago

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:password@secret-url.com/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

pashky commented 4 years ago

Drop the quotes, no need for them

lake-effect commented 4 years ago

Which ones?

pashky commented 4 years ago

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

lake-effect commented 4 years ago

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
failable commented 1 year ago

Any news?