Skip to main content

Test a Route

After you create a Route, send a test request to the Gateway URL of the API Gateway to confirm that the request passes through the API Gateway and that the Route forwards it to the backend. This page uses Postman as an example, but you can use any tool that sends HTTP requests, for example curl.

Configuration used in the example:

ComponentValue
API Gatewayanhdtp-2109, with the Gateway URL https://YOUR_GATEWAY_URL
Routeroute-echo: Protocols HTTPS, HTTP Methods GET, Paths /echo
Upstreamupstream-echo: Target Address = backend address, Port 443
warning

The API Gateway must be in the Active status and the Route must be in the Published status to receive requests. See View API Gateway details.

Step 1Copy the Gateway URL of the API Gateway
1 / 6
Step 1: Copy the Gateway URL of the API Gateway

Click the image to zoom in.

Test a Route​

Comparing the results before and after the Route exists shows clearly what the Route does. To test a Route, follow these steps:

  1. In the left menu, select API Gateway → Gateway. On the row of the API Gateway that holds the Route, click the copy icon in the Gateway URL column.

API Gateway list with the copy button in the Gateway URL column

  1. Send a GET request to the Gateway URL with the path to test, for example https://YOUR_GATEWAY_URL/echo. While the API Gateway has no Route that matches the /echo path, the result is 404 Not Found with the body {"error_msg":"404 Route Not Found"}. This means the request reached the API Gateway, but the API Gateway does not know where to forward it.

Postman gets 404 Route Not Found before the Route exists

  1. Create a Route that matches the request, see Create a Route. In the example, the route-echo Route accepts GET to the /echo path over HTTPS.

Routing Rules section of the route-echo Route with the GET method and the /echo path

On the Upstream tab (labeled REF) of the Route, check the backend address that the Route forwards requests to.

Upstream tab of the route-echo Route with the backend address in Target Address

  1. Send the same request as in Step 2 again. The result is 200 OK with the body returned by the backend. The response contains the X-Forwarded-Host header with the domain of the Gateway URL, and the X-Real-IP header.

Postman gets 200 OK when calling through the Gateway URL

  1. (Optional) Call the backend address directly to compare. The result is also 200 OK, but without the X-Forwarded-Host and X-Real-IP headers. The API Gateway adds these two headers, so the request in Step 4 went through the API Gateway.

Postman calls the backend address directly, and the response has no X-Forwarded-Host

Read the results​

ResultMeaning
404 Not Found, body {"error_msg":"404 Route Not Found"}The request reached the API Gateway, but no Route matches its protocol, method, and path.
200 OK, and the response has the X-Forwarded-Host header with the domain of the Gateway URLThe request passed through the API Gateway, matched the Route, and was forwarded to the backend.

Common errors​

ErrorCauseSolution
Still 404 Route Not Found after the Route is createdThe protocol, method, or path of the request does not match the Routing Rules, for example sending POST when the Route only accepts GETCompare the request with the Routing Rules section, see View Route details.
Still 404 Route Not Found although the request matches the Routing RulesThe Route is in the Unpublished statusChange Status to Published, see Edit a Route.
The request cannot reach the Gateway URLThe API Gateway is not in the Active status yetCheck the Status column in the API Gateway list, see View API Gateway details.

Next steps​

Last updated on