Capture any request sent to a bin
GETPOSTPUTPATCHDELETEHEADOPTIONS
https://api.testingapis.com/api/webhooks/{binId}/{rest}Accepts GET, POST, PUT, PATCH, DELETE, HEAD and OPTIONS. Text bodies are stored as UTF-8; other bodies are stored as base64. Bodies over 256KB are truncated (bodyTruncated: true). No outbound calls are ever made.
Parameters 3
| Name | Type | Description |
|---|---|---|
binIdrequired | path · string | Bin id from POST /api/webhooks/bins. |
restrequired | path · string | Optional extra path after the bin id, e.g. orders/created. It is recorded as subPath. |
status | query · integer (int32) | Status code to reply with (200-599, default 200). 204 and 304 reply without a body. Default: 200. |
Request body
Optional. application/json. Any payload; it is captured in the bin.
Responses
- 200
- Request captured (or the status chosen with status).
- 400
- status is out of range.
- 404
- No bin with that id.
Example
Request
curl -X POST "https://api.testingapis.com/api/webhooks/cbaa7309f444/github/push" \
-H "Content-Type: application/json"Response200 OK
{
"received": true,
"binId": "cbaa7309f444",
"requestId": "req_ff264204fa37",
"message": "Request captured"
}Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/webhooks/cbaa7309f444/github/push", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
});
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"POST",
"https://api.testingapis.com/api/webhooks/cbaa7309f444/github/push",
headers={
"Content-Type": "application/json",
},
allow_redirects=False,
)
print(response.status_code, response.text)Java (HttpClient)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NEVER)
.build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.testingapis.com/api/webhooks/cbaa7309f444/github/push"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}