Send Request Inside APIs with Azure Policy

Опубликовано: 04 Июнь 2026
на канале: Cloud Research & Software Engineering
482
1

The `send-request` policy in Azure API Management allows you to make HTTP requests from within the policy execution flow. It's a versatile policy that enables interactions with external services, backends, or even other endpoints within your API. This policy is often used for scenarios such as calling Azure Functions, external APIs, or other services.

Key aspects of the `send-request` policy include:

1. *Request Configuration:*
You can configure various aspects of the HTTP request, including the URL, HTTP method (GET, POST, PUT, etc.), headers, and request body.

2. *Response Handling:*
The policy allows you to capture the response from the external service, including headers and body, and store it in a variable for further processing.

3. *Timeout and Retries:*
You can set a timeout for the request, specifying how long the API Management service should wait for a response. Additionally, you can configure retry policies to handle transient errors.

4. *Conditional Execution:*
The `send-request` policy can be conditionally executed based on the outcome of a prior policy, allowing for dynamic and flexible policy execution flows.

Here's a basic example of using `send-request` to make an HTTP call:

In this example:
The `mode="new"` indicates that a new request is being initiated.
`response-variable-name="externalResponse"` specifies the variable to store the response.
`timeout="20"` sets a timeout of 20 seconds.
`ignore-error="false"` means that errors from the external request will not be ignored.

The response from the external service can then be accessed in subsequent policies using the variable specified in `response-variable-name`.

Always refer to the official Azure API Management documentation for the most up-to-date information on the `send-request` policy, as features and capabilities may be updated over time.