I have a whole series of curl commands that I would like convert into ob-http code blocks in a org file (second choice would be to do them in restclient).

Here is a simplified sample command:

curl -X POST
     --proxy http://my-proxy.local:9001 \
     --data "foo=bar" \
     --data "fizz=buzz" \
     --header "Content-Type:application/x-www-form-urlencoded" \
     --header "my-custom-header" \

(The resulting json passed back by this call would be used in the next call)

How can I convert the above into ob-http code block (or, restclient text file if ob-http cannot support)

I found this old question, but it does not fully cover my use case, and I didn't see in the linked docs how to accomplish the above conversion: How to test REST API with Emacs?

1 Answer 1


It's actually pretty straightforward:

#+begin_src http :proxy http://my-proxy.local:9001
POST http://my-server.local/my/endpoint


You can also write the post body in a single line. Multiple lines should be more readable for long parameter lists though. curl (which is used by ob-http for the actual call) will strip out the whitespaces anyway. If you use & at the beginning or end of the line is just a matter of taste. Using it at the beginning has the advantage that you only have to change one line when appending parameters (but it would be the other way around if you prefer to add them at the beginning).

The header Content-Type: application/x-www-form-urlencoded is set by default for POST, but you can also add it explicitly. Just add it as another line after POST along with the other header parameters.

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.