Last updated: March 14, 2017
An HTTP API for turning GETs into POSTs
Version 1 of the API. Stable since launch; the docs are the whole site.
The API is for clients that can only fetch an address. The request you want sent is written into a link; fetching the link sends it, and what the other side answers comes back to you.
Everything on this page is served from one host:
Requests go out to any public http or https address.
The full description, as plain text. A program can read it as easily as a person; the example on the right is the one it uses.
2Post Tech: An HTTP API for turning GETs into POSTs
Put the address and the body in a link and fetch it. This POSTs
{"hello":"from-a-link"} to https://httpbun.com/anything, which answers
with a description of the request it got, and gives you that answer,
status code and headers included:
https://www.2post.tech/api/forward?url=https://httpbun.com/anything&body=%7B%22hello%22%3A%22from-a-link%22%7D
With curl, which does the encoding for you:
curl -G https://www.2post.tech/api/forward --data-urlencode 'url=https://httpbun.com/anything' --data-urlencode 'body={"hello":"from-a-link"}'
Something other than a POST, or with headers of your own:
https://www.2post.tech/api/forward?url=https://httpbun.com/anything/7&method=DELETE
https://www.2post.tech/api/forward?url=https://httpbun.com/anything/7&method=PUT&body=name%3Dnew&headers=%7B%22Authorization%22%3A%22Bearer%20abc%22%7D
headers is a JSON object, here {"Authorization":"Bearer abc"}. A body
that is JSON goes out as application/json, a=1&b=2 as a form, anything
else as text; content_type=... says otherwise. Add response=json to
get the answer wrapped in an object with "status", "headers" and
"body". http and https only. Redirects are followed. No key, no
account.
The example request:
It is sent to a public test address, which answers with what it received.
Fill in a request and send it from here. The form makes the same kind of link as the one described above, so the address bar afterwards holds a link you can keep.
A link of the kind the form makes:
Fetch it with anything that can open an address.
A link can send any of these methods, with a body, and with headers of your own.
| Method | Usually means |
|---|---|
POST | Hand something new to the other side |
PUT | Replace what is there |
PATCH | Change part of what is there |
DELETE | Remove it |
How the method, the body and each header are written into the link is set out under Making a request.
Custom headers travel with the request to the other side.
What you get back is the other side's answer to the request that was sent for you. For what can go wrong, see Errors.
The answer returned is the other side's answer.