Link Search Menu Expand Document

Calculator API

APIM integrates well with external services via HTTP-based interaction.

This example shows a fire-and-forget send-one-way-request policy, which does not await a response. Alternatively, you can use a send-request policy to send a request and await a return. Some complex in-flight processing logic may also be better handled by using Logic Apps.

Send-One-Way-Request Setup

The following policy and payload applies for both examples in this lab. Please ensure that you replace the value in <set-url> with your webhook target URL. You will identify the URL in either example below.

  • Open the Add two integers operation in the Calculator API.
  • Open the ‘Code View’.
  • Add the send-one-way-request policy to Outbound processing and replace the webhook and payload as required. For demo purposes we are going to use the payload for a Teams message (even for and also send the message on every successful request.

      <base />
        <when condition="@(context.Response.StatusCode == 200)">
          <send-one-way-request mode="new">
              return new JObject(
                new JProperty("@type","MessageCard"),
                new JProperty("@context", ""),
                new JProperty("summary","Summary"),
                new JProperty("themeColor", "0075FF"),
                new JProperty("sections",
                  new JArray (
                    new JObject (
                      new JProperty("text", "Hello!")

Send a message to is a simple recipient to test webhook messages and requires no setup overhead, making this an ideal component in this lab, especially as we are not sending any sensitive information in our payload from our test APIM instance.

  • Go to and copy the value for Your unique URL.

    Webhook Site Setup

  • Use this URL as the value in the <set-url> property in the send-one-way-request policy.

  • Invoke the API from the APIM Test tab and observe the 200 success response.

  • Check the Trace for the Outbound one-way message.

    Webhook Site APIM Trace

  • Observe the success in the Webhook site.

    Webhook Site Success

Send a message to Microsoft Teams channel

An optional lab, for Microsoft Teams, please review Create an Incoming Webhook.

  • First, open Teams and enable a Webhook connector for your team.
    • Get the URL of the webhook.

      Teams Webhook

      Teams Webhook

      Teams Webhook

      Teams Webhook

  • Format the required payload. The payload sent to a Teams channel uses the MessageCard JSON schema. You can experiment with different cards in the MessageCard Playground.

  • Invoke the API from the Test tab and observe the 200 success response.

  • Look for a received message in your Teams channel:

    Teams APIM Message