New in 2.4: Test runs you can trust See what's new →

Parses a JSON body and describes its structure

POSThttps://api.testingapis.com/api/bodies/json

Accepts application/json and application/*+json.

Request body

Optional. application/json, application/*+json. Any JSON value: object, array or scalar.

Example body
{"name": "Ada", "skills": ["math", "code"], "active": true}

Responses

200
Root type, top-level keys or array length, and the parsed value.
400
Empty or malformed JSON.
415
Any other Content-Type.

Example

Request
curl -X POST "https://api.testingapis.com/api/bodies/json" \
  -H "Content-Type: application/json" \
  -d '{"name": "Ada", "skills": ["math", "code"], "active": true}'
Run in Studio
Response200 OK
{
  "contentType": "application/json",
  "rootType": "object",
  "keys": ["name", "skills", "active"],
  "length": null,
  "received": {"name": "Ada", "skills": ["math", "code"], "active": true}
}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/bodies/json", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: "{\"name\": \"Ada\", \"skills\": [\"math\", \"code\"], \"active\": true}",
});
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "POST",
    "https://api.testingapis.com/api/bodies/json",
    headers={
        "Content-Type": "application/json",
    },
    data="{\"name\": \"Ada\", \"skills\": [\"math\", \"code\"], \"active\": true}".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/bodies/json"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString("{\"name\": \"Ada\", \"skills\": [\"math\", \"code\"], \"active\": true}"))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}