I am trying to use request.el to make a simple post request in elisp to my API, running on localhost. Here is the request in restclient.el format that I am trying to make in elisp using request.el:
POST https://localhost/action/loginAuthenticate
Content-Type: application/json
{
"data":
{
"username": "usernamehere",
"password": "passwordhere"
}
}
Here is my attempt at making the request in elisp, using the documentation from https://github.com/tkf/emacs-request :
(require 'json)
(require 'request)
(setf debug-on-error t)
(request
"https://localhost/action/loginAuthenticate"
:type "POST"
:headers '(("Content-Type" . "application/json"))
:data (json-encode '(("data" ("username" . "usernamehere") ("password" . "passwordhere"))))
:parser 'json-read
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "Response is: %S" (request-response-data response)))))
I'm getting the following error message when using M-x eval-buffer
to evaluate my elisp code:
[error] request-default-error-callback: https://localhost/action/loginAuthenticate parse-error
I'm not sure what is causing this error. In addition, even though I've included the form (setf debug-on-error t)
and have also tried executing M-x toggle-debug-on-error
, I'm not getting any additional debug output in any emacs buffers. (I'm guessing the debug information is limited to the one line error message).
Finally, It's worth mentioning that the request is not making it to my API, which tells me the problem has to do with my code above.
What am I doing wrong here?