cURL JavaScript TypeScript Python C# Java Go
curl - X POST 'https://api.testingapis.com/api/People' \
- H 'Content-Type: application/json' \
- H 'X-TestingApis-Key: YOUR_API_KEY' \
- d '{"firstName": "Aisha", "lastName": "Khan", "username": "akhan", "email": "akhan@example.com", "gender": "female", "dateOfBirth": "1991-04-12", "phone": "+1-555-200-3000", "avatar": "https://i.pravatar.cc/150?img=1", "address": {"street": "42 Baker Street", "city": "London", "state": "England", "zip": "NW1 6XE", "country": "United Kingdom", "geo": {"lat": 51.5237, "lng": -0.1585}}, "company": {"name": "Nimbus Cloud Systems", "title": "Product Manager"}}' const res = await fetch("https://api.testingapis.com/api/People", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-TestingApis-Key": "YOUR_API_KEY",
},
body: "{\"firstName\": \"Aisha\", \"lastName\": \"Khan\", \"username\": \"akhan\", \"email\": \"akhan@example.com\", \"gender\": \"female\", \"dateOfBirth\": \"1991-04-12\", \"phone\": \"+1-555-200-3000\", \"avatar\": \"https://i.pravatar.cc/150?img=1\", \"address\": {\"street\": \"42 Baker Street\", \"city\": \"London\", \"state\": \"England\", \"zip\": \"NW1 6XE\", \"country\": \"United Kingdom\", \"geo\": {\"lat\": 51.5237, \"lng\": -0.1585}}, \"company\": {\"name\": \"Nimbus Cloud Systems\", \"title\": \"Product Manager\"}}",
});
console.log(res.status, await res.text());const res = await fetch("https://api.testingapis.com/api/People", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-TestingApis-Key": "YOUR_API_KEY",
},
body: "{\"firstName\": \"Aisha\", \"lastName\": \"Khan\", \"username\": \"akhan\", \"email\": \"akhan@example.com\", \"gender\": \"female\", \"dateOfBirth\": \"1991-04-12\", \"phone\": \"+1-555-200-3000\", \"avatar\": \"https://i.pravatar.cc/150?img=1\", \"address\": {\"street\": \"42 Baker Street\", \"city\": \"London\", \"state\": \"England\", \"zip\": \"NW1 6XE\", \"country\": \"United Kingdom\", \"geo\": {\"lat\": 51.5237, \"lng\": -0.1585}}, \"company\": {\"name\": \"Nimbus Cloud Systems\", \"title\": \"Product Manager\"}}",
});
const body: string = await res.text();
console.log(res.status, body);import requests
res = requests.post(
"https://api.testingapis.com/api/People",
headers={
"Content-Type": "application/json",
"X-TestingApis-Key": "YOUR_API_KEY",
},
data="{\"firstName\": \"Aisha\", \"lastName\": \"Khan\", \"username\": \"akhan\", \"email\": \"akhan@example.com\", \"gender\": \"female\", \"dateOfBirth\": \"1991-04-12\", \"phone\": \"+1-555-200-3000\", \"avatar\": \"https://i.pravatar.cc/150?img=1\", \"address\": {\"street\": \"42 Baker Street\", \"city\": \"London\", \"state\": \"England\", \"zip\": \"NW1 6XE\", \"country\": \"United Kingdom\", \"geo\": {\"lat\": 51.5237, \"lng\": -0.1585}}, \"company\": {\"name\": \"Nimbus Cloud Systems\", \"title\": \"Product Manager\"}}",
)
print(res.status_code, res.text)using System.Net.Http.Headers;
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, "https://api.testingapis.com/api/People");
request.Headers.TryAddWithoutValidation("X-TestingApis-Key", "YOUR_API_KEY");
request.Content = new StringContent("{\"firstName\": \"Aisha\", \"lastName\": \"Khan\", \"username\": \"akhan\", \"email\": \"akhan@example.com\", \"gender\": \"female\", \"dateOfBirth\": \"1991-04-12\", \"phone\": \"+1-555-200-3000\", \"avatar\": \"https://i.pravatar.cc/150?img=1\", \"address\": {\"street\": \"42 Baker Street\", \"city\": \"London\", \"state\": \"England\", \"zip\": \"NW1 6XE\", \"country\": \"United Kingdom\", \"geo\": {\"lat\": 51.5237, \"lng\": -0.1585}}, \"company\": {\"name\": \"Nimbus Cloud Systems\", \"title\": \"Product Manager\"}}");
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");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.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.testingapis.com/api/People"))
.header("X-TestingApis-Key", "YOUR_API_KEY")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"firstName\": \"Aisha\", \"lastName\": \"Khan\", \"username\": \"akhan\", \"email\": \"akhan@example.com\", \"gender\": \"female\", \"dateOfBirth\": \"1991-04-12\", \"phone\": \"+1-555-200-3000\", \"avatar\": \"https://i.pravatar.cc/150?img=1\", \"address\": {\"street\": \"42 Baker Street\", \"city\": \"London\", \"state\": \"England\", \"zip\": \"NW1 6XE\", \"country\": \"United Kingdom\", \"geo\": {\"lat\": 51.5237, \"lng\": -0.1585}}, \"company\": {\"name\": \"Nimbus Cloud Systems\", \"title\": \"Product Manager\"}}"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader("{\"firstName\": \"Aisha\", \"lastName\": \"Khan\", \"username\": \"akhan\", \"email\": \"akhan@example.com\", \"gender\": \"female\", \"dateOfBirth\": \"1991-04-12\", \"phone\": \"+1-555-200-3000\", \"avatar\": \"https://i.pravatar.cc/150?img=1\", \"address\": {\"street\": \"42 Baker Street\", \"city\": \"London\", \"state\": \"England\", \"zip\": \"NW1 6XE\", \"country\": \"United Kingdom\", \"geo\": {\"lat\": 51.5237, \"lng\": -0.1585}}, \"company\": {\"name\": \"Nimbus Cloud Systems\", \"title\": \"Product Manager\"}}")
req, err := http.NewRequest("POST", "https://api.testingapis.com/api/People", body)
if err != nil {
panic(err)
}
req.Header.Set("X-TestingApis-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(res.StatusCode, string(data))
}