Echoes back everything the server received
GETPOSTPUTPATCHDELETEHEADOPTIONS
https://api.testingapis.com/api/echo/{path}Echoes back everything the server received: method, URL, query, headers, cookies, body and client info.
Accepts GET, POST, PUT, PATCH, DELETE, HEAD and OPTIONS on /api/echo and on any sub-path (/api/echo/{**path}); the sub-path is returned as subPath. Up to 1MB of body is echoed (UTF-8 text, or base64 for binary); larger bodies are counted in contentLength and flagged with bodyTruncated. JSON bodies are also returned parsed in json (or jsonError when malformed), and form bodies as form fields plus files metadata. Example: POST /api/echo/orders/7?tag=a&tag=b with a JSON body.
Parameters 1
| Name | Type | Description |
|---|---|---|
pathrequired | path · string |
Request body
Optional. application/json. Any body; it is echoed back.
Example body
{"hello": "world"}Responses
- 200
- The request as the server saw it (HEAD responses carry headers only).
Example
Request
curl -X POST "https://api.testingapis.com/api/echo/orders/42" \
-H "Content-Type: application/json" \
-d '{"hello": "world"}'Response200 OK
{
"method": "POST",
"url": "https://api.testingapis.com/api/echo/orders/42",
"path": "/api/echo/orders/42",
"subPath": "orders/42",
"queryString": "",
"query": {},
"headers": {
"Accept": "*/*",
"Connection": "keep-alive",
"Host": "api.testingapis.com",
"User-Agent": "python-requests/2.33.1",
"Accept-Encoding": "gzip, deflate, zstd",
"Content-Type": "application/json",
… (18 more lines)Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/echo/orders/42", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: "{\"hello\": \"world\"}",
});
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"POST",
"https://api.testingapis.com/api/echo/orders/42",
headers={
"Content-Type": "application/json",
},
data="{\"hello\": \"world\"}".encode("utf-8"),
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/echo/orders/42"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"hello\": \"world\"}"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}