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

Forward a request to an upstream URL and relay its response

POSThttps://api.testingapis.com/api/Proxy/call

Returns 200 with the upstream status, statusText and raw body (as a string) whatever the upstream status was.

Note: Forwards any HTTP request server-side and returns the upstream status and raw body.

Request body

Optional. application/json, text/json, application/*+json, application/xml, text/xml, application/*+xml. Model: ApiRequestData. endpointUrl (absolute http or https URL), methodName (GET, POST, ...) and an optional requestBody, sent as JSON except for GET and HEAD.

Example body
{"endpointUrl": "https://httpbin.org/get", "methodName": "GET", "requestBody": ""}

Responses

200
Upstream status, statusText and body.
400
endpointUrl isn't an absolute http(s) URL, or methodName is missing.
502
The upstream request failed or timed out.

Example

Request
curl -X POST "https://api.testingapis.com/api/Proxy/call" \
  -H "Content-Type: application/json" \
  -d '{"endpointUrl": "https://httpbin.org/get", "methodName": "GET", "requestBody": ""}'
Run in Studio
Response200 OK
{
  "status": 200,
  "statusText": "OK",
  "body": {\n  \args\: {}, \n  \headers\: {\n    \Host\: \httpbin.org\, \n    \Traceparent\: \00-28f8fb2606d6a8a5236ddc630313607a-65e44e7a…
}

Code examples

JavaScript (fetch)
const response = await fetch("https://api.testingapis.com/api/Proxy/call", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: "{\"endpointUrl\": \"https://httpbin.org/get\", \"methodName\": \"GET\", \"requestBody\": \"\"}",
});
console.log(response.status, await response.text());
Python (requests)
import requests

response = requests.request(
    "POST",
    "https://api.testingapis.com/api/Proxy/call",
    headers={
        "Content-Type": "application/json",
    },
    data="{\"endpointUrl\": \"https://httpbin.org/get\", \"methodName\": \"GET\", \"requestBody\": \"\"}".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/Proxy/call"))
            .header("Content-Type", "application/json")
            .method("POST", HttpRequest.BodyPublishers.ofString("{\"endpointUrl\": \"https://httpbin.org/get\", \"methodName\": \"GET\", \"requestBody\": \"\"}"))
            .build();

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