Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:noheaders argument does not work with file output #26

Closed
betaprior opened this issue Aug 4, 2021 · 1 comment · Fixed by #42
Closed

:noheaders argument does not work with file output #26

betaprior opened this issue Aug 4, 2021 · 1 comment · Fixed by #42

Comments

@betaprior
Copy link

betaprior commented Aug 4, 2021

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
@velppa
Copy link

velppa commented Oct 25, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants