ob-restclient.el
ob-restclient.el copied to clipboard
:noheaders argument does not work with file output
I need to write the output of an API call to a JSON file without the headers. Unfortunately, it doesn't seem like I can do this with ob-restclient. In particular, I am trying to replicate the result of the following, but with ob-restclient:
#+begin_src shell :results output file :file localhost-test-token1.json :output-dir ~/tmp
curl -X POST -d '{"username": "admin", "password": "admin"}' -H 'Content-Type: application/json' http://localhost:8080/login
#+end_src
I was hoping that the following would do the trick, however the headers are still getting printed to the file:
#+begin_src restclient :noheaders :results value file :file localhost-test-token.json :output-dir ~/tmp
POST http://localhost:8080/login
Content-Type: application/json
{
"username": "admin",
"password": "admin"
}
#+end_src
I bumped into the same problem, it's caused by org-babel-restclient--raw-payload-p
which is used when "file" exists in params, so it causes rest client to return raw output, and headers there are not commented, so :noheaders handling has no effect.
I solved it by redefining the function as follows:
(defun org-babel-restclient--raw-payload-p (params) nil)