Receive and respond to inbound HTTPS requests in Azure Logic Apps

With Azure Logic Apps and the built-in Request trigger and Response action, you can create automated tasks and workflows that receive and respond to incoming HTTPS requests. For example, you can have your logic app:

  • Receive and respond to an HTTPS request for data in an on-premises database.
  • Trigger a workflow when an external webhook event happens.
  • Receive and respond to an HTTPS call from another logic app.

The Request trigger supports Azure Active Directory Open Authentication (Azure AD OAuth) for authorizing inbound calls to your logic app. For more information about enabling this authentication, see Secure access and data in Azure Logic Apps - Enable Azure AD OAuth authentication.

Note

The Request trigger supports only Transport Layer Security (TLS) 1.2 for incoming calls. Outgoing calls support TLS 1.0, 1.1, and 1.2. For more information, see Solving the TLS 1.0 problem.

If you get TLS handshake errors, make sure that you use TLS 1.2. For incoming calls, here are the supported cipher suites:

  • TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
  • TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
  • TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
  • TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256

Prerequisites

Add Request trigger

This built-in trigger creates a manually callable HTTPS endpoint that can receive only incoming HTTPS requests. When this event happens, the trigger fires and runs the logic app. For more information about the trigger's underlying JSON definition and how to call this trigger, see the Request trigger type and Call, trigger, or nest workflows with HTTPS endpoints in Azure Logic Apps.

  1. Sign in to the Azure portal. Create a blank logic app.

  2. After Logic App Designer opens, in the search box, enter http request as your filter. From the triggers list, select the When an HTTP request is received trigger, which is the first step in your logic app workflow.

    Select Request trigger

    The Request trigger shows these properties:

    Request trigger

    Property name JSON property name Required Description
    HTTP POST URL {none} Yes The endpoint URL that's generated after you save the logic app and is used for calling your logic app
    Request Body JSON Schema schema No The JSON schema that describes the properties and values in the incoming request body
  3. In the Request Body JSON Schema box, optionally enter a JSON schema that describes the body in the incoming request, for example:

    Example JSON schema

    The designer uses this schema to generate tokens for the properties in the request. That way, your logic app can parse, consume, and pass along data from the request through the trigger into your workflow.

    Here is the sample schema:

    {
       "type": "object",
       "properties": {
          "account": {
             "type": "object",
             "properties": {
                "name": {
                   "type": "string"
                },
                "ID": {
                   "type": "string"
                },
                "address": {
                   "type": "object",
                   "properties": {
                      "number": {
                         "type": "string"
                      },
                      "street": {
                         "type": "string"
                      },
                      "city": {
                         "type": "string"
                      },
                      "state": {
                         "type": "string"
                      },
                      "country": {
                         "type": "string"
                      },
                      "postalCode": {
                         "type": "string"
                      }
                   }
                }
             }
          }
       }
    }
    

    When you enter a JSON schema, the designer shows a reminder to include the Content-Type header in your request and set that header value to application/json. For more information, see Handle content types.

    Reminder to include "Content-Type" header

    Here's what this header looks like in JSON format:

    {
       "Content-Type": "application/json"
    }
    

    To generate a JSON schema that's based on the expected payload (data), you can use a tool such as JSONSchema.net, or you can follow these steps:

    1. In the Request trigger, select Use sample payload to generate schema.

      Generate schema from payload

    2. Enter the sample payload, and select Done.

      Generate schema from payload

      Here is the sample payload:

      {
         "account": {
            "name": "Contoso",
            "ID": "12345",
            "address": { 
               "number": "1234",
               "street": "Anywhere Street",
               "city": "AnyTown",
               "state": "AnyState",
               "country": "USA",
               "postalCode": "11111"
            }
         }
      }
      
  4. To check that the inbound call has a request body that matches your specified schema, follow these steps:

    1. In the Request trigger's title bar, select the ellipses button (...).

    2. In the trigger's settings, turn on Schema Validation, and select Done.

      If the inbound call's request body doesn't match your schema, the trigger returns an HTTP 400 Bad Request error.

  5. To specify additional properties, open the Add new parameter list, and select the parameters that you want to add.

    Property name JSON property name Required Description
    Method method No The method that the incoming request must use to call the logic app
    Relative path relativePath No The relative path for the parameter that the logic app's endpoint URL can accept

    This example adds the Method property:

    Add Method parameter

    The Method property appears in the trigger so that you can select a method from the list.

    Select method

  6. Now, add another action as the next step in your workflow. Under the trigger, select Next step so that you can find the action that you want to add.

    For example, you can respond to the request by adding a Response action, which you can use to return a customized response and is described later in this topic.

    Your logic app keeps the incoming request open only for a limited time. Assuming that your logic app workflow includes a Response action, if the logic app doesn't return a response after this time passes, your logic app returns a 504 GATEWAY TIMEOUT to the caller. Otherwise, if your logic app doesn't include a Response action, your logic app immediately returns a 202 ACCEPTED response to the caller.

  7. When you're done, save your logic app. On the designer toolbar, select Save.

    This step generates the URL to use for sending the request that triggers the logic app. To copy this URL, select the copy icon next to the URL.

    URL to use triggering your logic app

    Note

    If you want to include the hash or pound symbol (#) in the URI when making a call to the Request trigger, use this encoded version instead: %25%23

  8. To trigger your logic app, send an HTTP POST to the generated URL.

    For example, you can use a tool such as Postman to send the HTTP POST. If you enabled Azure Active Directory Open Authentication (Azure AD OAuth) for authorizing inbound calls to the Request trigger, either call the trigger by using a Shared Access Signature (SAS) URL or by using an authentication token, but you can't use both. The authentication token must specify the Bearer type in the authorization header. For more information, see Secure access and data in Azure Logic Apps - Access to request-based-triggers.

For more information about the trigger's underlying JSON definition and how to call this trigger, see these topics, Request trigger type and Call, trigger, or nest workflows with HTTP endpoints in Azure Logic Apps.

Trigger outputs

Here's more information about the outputs from the Request trigger:

JSON property name Data type Description
headers Object A JSON object that describes the headers from the request
body Object A JSON object that describes the body content from the request

Add a Response action

You can use the Response action to respond with a payload (data) to an incoming HTTPS request but only in a logic app that's triggered by an HTTPS request. You can add the Response action at any point in your workflow. For more information about the underlying JSON definition for this trigger, see the Response action type.

Your logic app keeps the incoming request open only for a limited time. Assuming that your logic app workflow includes a Response action, if the logic app doesn't return a response after this time passes, your logic app returns a 504 GATEWAY TIMEOUT to the caller. Otherwise, if your logic app doesn't include a Response action, your logic app immediately returns a 202 ACCEPTED response to the caller.

Important

If a Response action includes these headers, Logic Apps removes these headers from the generated response message without showing any warning or error:

  • Allow
  • Content-* with these exceptions: Content-Disposition, Content-Encoding, and Content-Type
  • Cookie
  • Expires
  • Last-Modified
  • Set-Cookie
  • Transfer-Encoding

Although Logic Apps won't stop you from saving logic apps that have a Response action with these headers, Logic Apps ignores these headers.

  1. In the Logic App Designer, under the step where you want to add a Response action, select New step.

    For example, using the Request trigger from earlier:

    Add new step

    To add an action between steps, move your pointer over the arrow between those steps. Select the plus sign (+) that appears, and then select Add an action.

  2. Under Choose an action, in the search box, enter "response" as your filter, and select the Response action.

    Select the Response action

    The Request trigger is collapsed in this example for simplicity.

  3. Add any values that are required for the response message.

    In some fields, clicking inside their boxes opens the dynamic content list. You can then select tokens that represent available outputs from previous steps in the workflow. Properties from the schema specified in the earlier example now appear in the dynamic content list.

    For example, for the Headers box, include Content-Type as the key name, and set the key value to application/json as mentioned earlier in this topic. For the Body box, you can select the trigger body output from the dynamic content list.

    Response action details

    To view the headers in JSON format, select Switch to text view.

    Headers - Switch to text view

    Here is more information about the properties that you can set in the Response action.

    Property name JSON property name Required Description
    Status Code statusCode Yes The status code to return in the response
    Headers headers No A JSON object that describes one or more headers to include in the response
    Body body No The response body
  4. To specify additional properties, such as a JSON schema for the response body, open the Add new parameter list, and select the parameters that you want to add.

  5. When you're done, save your logic app. On the designer toolbar, select Save.

Next steps