Passing org variables doesn't work
AsterOps opened this issue · 2 comments
AsterOps commented
Hi, I try to pass variable from one source block to restclient
source block, but it seems doesn't work.
#+name: auth
#+begin_src emacs-lisp
(base64-encode-string "test:123456")
#+end_src
#+RESULTS: auth
: dGVzdDoxMjM0NTY=
#+begin_src restclient :var VAR=auth
GET http://localhost:8080/some-endpoint
Authorization: Basic $VAR
#+end_src
#+RESULTS:
#+BEGIN_SRC js
// GET http://localhost:8080/some-endpoint
// HTTP/1.1 401 Unauthorized
...
#+END_SRC
When I wirte straightforward basic auth it works
#+begin_src restclient
GET http://localhost:8080/some-endpoint
Authorization: Basic dGVzdDoxMjM0NTY=
#+end_src
#+RESULTS:
#+BEGIN_SRC js
[
"some-content"
]
// GET http://localhost:8080/some-endpoint
// HTTP/1.1 200
...
#+END_SRC
When I try to simply print this variable in shell it's work
#+begin_src sh :var VAR=auth
echo $VAR
#+end_src
#+RESULTS:
: dGVzdDoxMjM0NTY=
I tried also with different types of results (raw etc.) but the effect was the same. Is it something I do wrong or maybe is it some workaround? Thx
Patryk27 commented
ob-restclient passes variables as-is into restclient, so you have to refer to them via :
, e.g.:
#+begin_src restclient :var auth=auth
PUT http://my-service.io
Authorization: Bearer :auth
#+end_src