Accepts only OPTIONS and lists the per-verb test endpoints
OPTIONS
https://api.testingapis.com/api/methods/optionsA plain OPTIONS request reaches this action. A CORS preflight (with Origin and Access-Control-Request-Method) is answered by the CORS middleware instead.
Responses
- 200
- An Allow header plus the endpoint list.
- 405
- Any other verb.
Example
Request
curl -X OPTIONS "https://api.testingapis.com/api/methods/options"Response200 OK
Allow: OPTIONS
{
"method": "OPTIONS",
"message": "OPTIONS request received.",
"endpoints": [
{"method": "GET", "path": "/api/methods/get"},
{"method": "POST", "path": "/api/methods/post"},
"… 5 more items"
]
}Code examples
JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/methods/options", {
method: "OPTIONS",
});
console.log(response.status, await response.text());Python (requests)
import requests
response = requests.request(
"OPTIONS",
"https://api.testingapis.com/api/methods/options",
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/methods/options"))
.method("OPTIONS", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}