title | description | services | author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|
Azure API Management policy reference - send-one-way-request | Microsoft Docs |
Reference for the send-one-way-request policy available for use in Azure API Management. Provides policy usage, settings, and examples. |
api-management |
dlepow |
api-management |
article |
12/08/2022 |
danlep |
The send-one-way-request
policy sends the provided request to the specified URL without waiting for a response.
[!INCLUDE api-management-policy-generic-alert]
<send-one-way-request mode="new | copy" timeout="time in seconds">
<set-url>request URL</set-url>
<set-method>...</set-method>
<set-header>...</set-header>
<set-body>...</set-body>
<authentication-certificate thumbprint="thumbprint" />
</send-one-way-request>
Attribute | Description | Required | Default |
---|---|---|---|
mode | Determines whether this is a new request or a copy of the current request. In outbound mode, mode=copy does not initialize the request body. Policy expressions are allowed. |
No | new |
timeout | The timeout interval in seconds before the call to the URL fails. Policy expressions are allowed. | No | 60 |
Element | Description | Required |
---|---|---|
set-url | The URL of the request. Policy expressions are allowed. | No if mode=copy ; otherwise yes. |
set-method | Sets the method of the request. Policy expressions aren't allowed. | No if mode=copy ; otherwise yes. |
set-header | Sets a header in the request. Use multiple set-header elements for multiple request headers. |
No |
set-body | Sets the body of the request. | No |
authentication-certificate | Certificate to use for client authentication, specified in a thumbprint attribute. |
No |
- Policy sections: inbound, outbound, backend, on-error
- Policy scopes: global, workspace, product, API, operation
- Gateways: dedicated, consumption, self-hosted
This example uses the send-one-way-request
policy to send a message to a Slack chat room if the HTTP response code is greater than or equal to 500. For more information on this sample, see Using external services from the Azure API Management service.
<choose>
<when condition="@(context.Response.StatusCode >= 500)">
<send-one-way-request mode="new" timeout="20">
<set-url>https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX</set-url>
<set-method>POST</set-method>
<set-body>@{
return new JObject(
new JProperty("username","APIM Alert"),
new JProperty("icon_emoji", ":ghost:"),
new JProperty("text", String.Format("{0} {1}\nHost: {2}\n{3} {4}\n User: {5}",
context.Request.Method,
context.Request.Url.Path + context.Request.Url.QueryString,
context.Request.Url.Host,
context.Response.StatusCode,
context.Response.StatusReason,
context.User.Email
))
).ToString();
}</set-body>
</send-one-way-request>
</when>
</choose>
[!INCLUDE api-management-policy-ref-next-steps]