cURL JavaScript TypeScript Python C# Java Go
curl - X DELETE 'https://api.testingapis.com/api/Photos/51' \
- H 'X-TestingApis-Key: YOUR_API_KEY' const res = await fetch("https://api.testingapis.com/api/Photos/51", {
method: "DELETE",
headers: {
"X-TestingApis-Key": "YOUR_API_KEY",
},
});
console.log(res.status, await res.text());// The shape of the example response in the docs.
type ApiResponse = {
message: string;
};
const res = await fetch("https://api.testingapis.com/api/Photos/51", {
method: "DELETE",
headers: {
"X-TestingApis-Key": "YOUR_API_KEY",
},
});
const body = (await res.json()) as ApiResponse;
console.log(res.status, body);import requests
res = requests.delete(
"https://api.testingapis.com/api/Photos/51",
headers={
"X-TestingApis-Key": "YOUR_API_KEY",
},
)
print(res.status_code, res.text)using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Delete, "https://api.testingapis.com/api/Photos/51");
request.Headers.TryAddWithoutValidation("X-TestingApis-Key", "YOUR_API_KEY");
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/Photos/51"))
.header("X-TestingApis-Key", "YOUR_API_KEY")
.DELETE()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, err := http.NewRequest("DELETE", "https://api.testingapis.com/api/Photos/51", nil)
if err != nil {
panic(err)
}
req.Header.Set("X-TestingApis-Key", "YOUR_API_KEY")
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))
}