0

I'm trying to construct an Org-based pipeline for some DevOps activities. Part of this requires making REST API calls and proceeding based on the results of those calls. I'm using ob-restclient for making actual requests. One example would be:

#+name: applications
#+begin_src restclient :output value raw
  GET :host/rest/deploy/application
  Authorization: Basic :auth
  Connection: keep-alive
  Accept: application/json
  Content-Type: application/json
#+end_src

:host and :auth are variables that I define elsewhere. Now, this works fine, except the RESULTS section looks like this:

#+RESULTS: applications
#+BEGIN_SRC js
[
  {
    ...
  }
  ...
]

// <some response headers>
#+END_SRC

I want to be able to use the named result (applications) as input variable to another code block, but the problem is, it's not a pure JSON string, but also contains the JS codeblock markers and the response headers. Any idea how I could get only the JSON part without parsing this string output? I suspect this might be configurable on restclient's side, but I was unable to find a solution.

2
  • There is no org-babel header named :output AFAICT. An individual engine might define it but I don't see such in ob-restclient.el. Try :results value.
    – NickD
    Mar 26, 2021 at 21:36
  • Tried that as well. I think this is just something that's restclient specific. I bypassed the problem by using a function to post-process the result (found one here). Mar 27, 2021 at 15:14

1 Answer 1

2

I know it has been a long time since this was asked, but in the current version of ob-restclient (20220819.2228), I am able to show only results by using the :jq option:

#+begin_src restclient :results pure :jq .
  GET :host/rest/deploy/application
  Authorization: Basic :auth
  Connection: keep-alive
  Accept: application/json
  Content-Type: application/json
#+end_src

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.