Send one way request

APPLIES TO: All API Management tiers

The send-one-way-request policy sends the provided request to the specified URL without waiting for a response.

Note

Set the policy's elements and child elements in the order provided in the policy statement. Learn more about how to set or edit API Management policies.

Policy statement

<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>

Attributes

Attribute Description Required Default
mode Determines whether this is a new request or a copy of the headers and body in the current request. In the outbound policy section, 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

Elements

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
proxy Routes request via HTTP proxy. No

Usage

Example

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>

For more information about working with policies, see: