HTTP

The HTTP connector provides connectivity to HTTP service and allows you to consume HTTP based APIs. The connector also supports SSL/TLS connectivity through custom configuration and supports various authentication mechanisms like OAuth 2.0 Client Credentials Grant, Basic, and Digest.

Before you begin

Before using the HTTP connector, do the following tasks:

Configure the connector

A connection is specific to a data source. It means that if you have many data sources, you must create a separate connection for each data source. To create a connection, do the following:

  • In the Cloud console, go to the Integration Connectors > Connections page and then select or create a Google Cloud project.

    Go to the Connections page

  • Click + Create New to open the Create Connection page.
  • In the Location section, choose the location for the connection.
    1. Region: Select a location from the drop-down list.

      For the list of all the supported regions, see Locations.

    2. Click Next.
  • In the Connection Details section, complete the following:
  • Connector: Select HTTP from the drop down list of available Connectors.
  • Connector version: Select the Connector version from the drop down list of available versions.
  • In the Connection Name field, enter a name for the Connection instance.

    Connection names must meet the following criteria:

  • Optionally, enter a Description for the connection instance.
  • Optionally, enable Cloud logging, and then select a log level. By default, the log level is set to Error.
  • Service Account: Select a service account that has the required roles.
  • Optionally, to check the status of the connection, in the Status Check field, specify an endpoint URL. The URL can also include an endpoint attachment IP address. The status is active by default.
  • Optionally, configure the Connection node settings:

    A node is a unit (or replica) of a connection that processes transactions. More nodes are required to process more transactions for a connection and conversely, fewer nodes are required to process fewer transactions. To understand how the nodes affect your connector pricing, see Pricing for connection nodes. If you don't enter any values, by default the minimum nodes are set to 2 (for better availability) and the maximum nodes are set to 50.

  • Use proxy: Select the checkbox to configure a proxy server for the connection.
    1. Click + Add destination.
    2. Select a Destination Type.
      • Host address: Specify the hostname or IP address of the destination.

        If you want to establish private connection to your backend, do the following:

  • Optionally, click + ADD LABEL to add a label to the Connection in the form of a key/value pair.
  • Optionally, if you want to use SSL, select Enable SSL. This displays the SSL configuration details.
    1. Select a trust store type. It can be either Public, Private, or Insecure Connection.
    2. Select the certificates as displayed based on your trust store selection.
    3. If you use a self-signed certificate or a private trust store certificate, store the root certificate as a Secret Manager Secret in PEM (Privacy Enhanced Mail) format, and then in Custom Trust Store, select the required secret.
    4. If you are using mTLS, select the key store certificates in the Key Store section.
    5. Optionally, select the TLS version.
    6. Enter the supported cipher suite. Enter multiple cipher suites, as comma separated values. For more information, see Supported cipher suites.
  • Click Next.
  • In the Destinations section, enter details of the remote host (backend system) you want to connect to.
    1. Destination Type: Select a Destination Type.
      • To specify the destination hostname or IP address, select Host address and enter the address in the Host 1 field.
      • To establish a private connection, select Host Address and add the endpoint attachment created for the SAP Gateway using the HTTPS protocol.

      If you want to establish a public connection to your backend systems with additional security, you can consider configuring static outbound IP addresses for your connections, and then configure your firewall rules to allowlist only the specific static IP addresses.

      To enter additional destinations, click + Add destination.

    2. Click Next.
  • In the Authentication section, enter the authentication details.
    1. Select an Authentication type and enter the relevant details.

      The following authentication types are supported by the HTTP connection:

    2. To understand how to configure these authentication types, see Configure authentication.

    3. Click Next.
  • Review: Review your connection and authentication details.
  • Click Create.
  • Configure authentication

    Enter the details based on the authentication you want to use.

    Supported cipher suites

    TLS version Supported cipher suites
    1.2
    • TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
    • TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
    • TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
    • TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
    • TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    • TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
    • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
    • TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
    • TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
    • TLS_DHE_RSA_WITH_AES_128_CBC_SHA
    • TLS_DHE_RSA_WITH_AES_256_CBC_SHA
    • TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
    • TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
    1.3
    • TLS_AES_256_GCM_SHA384
    • TLS_CHACHA20_POLY1305_SHA256
    • TLS_AES_128_GCM_SHA256

    Additional steps after connection creation

    If you selected OAuth 2.0 - Authorization code for authentication, you must do the following additional steps after creating the connection:

    1. In the Connections page, locate the newly created connection.

      Notice that the Status for the new connector will be Authorization required.

    2. Click Authorization required.

      This shows the Edit authorization pane.

    3. Copy the Redirect URI value to your external application.
    4. Verify the authorization details.
    5. Click Authorize.

      If the authorization is successful, the connection status will be set to Active in the Connections page.

    Re-authorization for Authorization code

    If you are using Authorization code authentication type and have made any cofiguration changes in your backend HTTP application, you must re-authorize your HTTP connection. To re-authorize a connection, perform the following steps:

    1. Click on the required connection in the Connections page.

      This opens the connection details page.

    2. Click Edit to edit the connection details.
    3. Verify the OAuth 2.0 - Authorization code details in the Authentication section.

      If required, make the necessary changes.

    4. Click Save. This takes you to the connection details page.
    5. Click Edit authorization in the Authentication section. This shows the Authorize pane.
    6. Click Authorize.

      If the authorization is successful, the connection status will be set to Active in the Connections page.

    Entities, operations, and actions

    All the Integration Connectors provide a layer of abstraction for the objects of the connected application. You can access an application's objects only through this abstraction. The abstraction is exposed to you as entities, operations, and actions.

    System limitations

    Supported actions

    The HTTP connector supports the following actions:

    HttpRequest action

    The HTTP connector guarantees at least one attempt to send the request to the configured endpoint. This is subject to Application Integration Service Level Agreement (SLA). The following tables describe the input and output parameters of the HttpRequest action.

    Input parameters of the HttpRequest action

    Parameter name Data type Required Description
    Url Struct No URL for which you want to send the request. The URL has the format <scheme>://<netloc>/<path>;<params>?<query>#<fragment>. If you provide netloc, it overrides the hostname provided during connection creation.
    Method String No HTTP request method such as GET, POST, DELETE, or PUT. The default value is GET.
    Headers Struct No HTTP request headers.
    Body String No HTTP request body.
    RequestHasBytes Boolean No Whether to send request as bytes. If set to true, you must send the request as a Base64 encoded string in the Body parameter. The default value is false.
    ResponseHasBytes Boolean No Whether to receive the response as bytes. If set to true, you will receive the response as a Base64 encoded string in the ResponseBody output parameter. The default value is false.
    HttpVersion String No HTTP version to be used when making a request. The supported values are 1.1 and 2. If you specify version 2, ALPN (Application-Layer Protocol Negotiation) negotiation takes place and version 1.1 will be used if the server doesn't support version 2. The default value is 2.
    ResponseFormat String No Specifies the format of the response from the connector. The supported values are v1 and v2. The default value is v1.

    Sample v1 response:

    [{
    "ResponseBody": "{\n \"status\": 200\n}"
    }, {
    "StatusCode": 200.0
    }, {
    "HttpVersion": "2"
    }, {
    "ResponseHeaders": {
    ":status": "200",
    "content-length": "19"
    }
    }]

    Sample v2 response:

    [{
    "ResponseBody": "{\n \"status\": 200\n}",
    "StatusCode": 200.0,
    "HttpVersion": "2",
    "ResponseHeaders": {
    ":status": "200",
    "content-length": "19"
    }
    }]
    FailOnError Boolean No Specifies the behavior of the connection when there is an error in your backend application.
    • true - Throws an exception. The exception thrown by your backend is propagated in the connection's response.
    • false - Does not throw an exception. But returns the error code and the error message in the response.

    The default value is true.

    Timeout Integer No Timeout value for HTTP request in seconds. Maximum allowed value is 150 seconds.

    Output parameters of the HttpRequest action

    Parameter name Data type Description
    ResponseBody String Response received from the HTTP server.
    StatusCode Integer Status code received from the HTTP Server.
    HttpVersion String Version negotiated for the HTTP Request.
    ResponseHeaders Struct HTTP response headers in the form of key,value pairs.

    Examples

    This examples in this section describe the following operations:

    The following table lists the sample scenarios and the corresponding configuration in the Connectors task:

    Task Configuration
    Configure a request payload
    1. In the Configure connector task dialog, click Actions.
    2. Select the HttpRequest action, and then click Done.
    3. In the Task Input section of the Connectors task, click connectorInputPayload and then enter a value similar to the following in the Default Value field:
      {
        "Url": {
          "scheme": "https",
          "netloc": "httpbin.org",
          "path": "post",
          "query": "example=A&sort=value",
          "fragment": "exampleFragment"
        },
        "Method": "POST",
        "Headers": {
          "Accept": ["application/json", "application/xml"],
          "a": "b"
        },
        "Body": "{\"thisIsRequestJSON\":\"someValue\"}"
      }
    4. Click Save.

    This example makes a POST request to the https://httpbin.org/post?example=A&=value#exampleFragment URL. And because netloc is provided in the payload, it overrides the hostname provided during the connection creation.

    Send bytes content

    To send bytes (like files) content, you must set the RequestHasBytes request attribute to true, and set the body attribute to the Base64 encoded string that you want to send, as shown in the following sample.

    1. In the Configure connector task dialog, click Actions.
    2. Select the HttpRequest action, and then click Done.
    3. In the Task Input section of the Connectors task, click connectorInputPayload and then enter a value similar to the following in the Default Value field:
      {
        "Url": {
          "scheme": "https",
          "netloc": "httpbin.org",
        },
        "Method": "POST",
        "Headers": {
          "Accept": ["application/json", "application/xml"],
          "a": "b"
        },
        "Body": "SGVsbG8gV29ybGQ=",
        "RequestHasBytes":true
      }
    4. Click Save.

    This example makes a POST request to the httpbin.org server, and in the request body sends the file content in the form of a Base64 encoded string. The server can decide on how to process the file content.

    Get bytes content

    To get bytes (as Base64 string) from the server, you must set the ResponseHasBytes request attribute to true as shown in the following sample.

    1. In the Configure connector task dialog, click Actions.
    2. Select the HttpRequest action, and then click Done.
    3. In the Task Input section of the Connectors task, click connectorInputPayload and then enter a value similar to the following in the Default Value field:
      {
        "Url": {
          "scheme": "https",
          "netloc": "httpbin.org",
        },
        "Method": "GET",
        "ResponseHasBytes":true
      }
    4. Click Save.

    This example makes a GET request to the httpbin.org server, and in the request body sets the ResponseHasBytes to true.

    Error codes

    This section descries the error messages that you might get when using the HTTP connection.

    Error message Cause
    Error connecting with the HTTP server The HTTP connection failed to establish connection with the server because of SSL handshake failure or an incorrect HTTP server endpoint.
    Error response received from the HTTP server The HTTP server you are trying to connect returns an error response with status code 4xx or 5xx. Sample response:
    {
      "error": {
        "code": 400,
        "details": [
          {
            "@type": "type.googleapis.com/google.rpc.ErrorInfo",
            "metadata": {
              "Body": "{\"thisIsResponseJSON\":\"someValue\"}"
              "Error": "Error response received from the HTTP server",
              "Headers": "{\":status\":[\"400\"], \"access-control-allow-credentials\":[\"true\"]}",
              "StatusCode": "400",
              "connection_type": "Http"
            }
          }
        ],
        "message": "Unable to execute HTTP Request",
        "status": "FAILED_PRECONDITION"
      }
    }
    Error while fetching access token There was an error when retrieving access token for the OAuth Client Credentials Grant authentication type.
    Digest Auth Error The connector runtime hasn't received a digest challenge or the challenge is of unsupported type.
    Error 400 The HTTP server returns an error response with status code 400. Check the response body for more details.

    Create connections using Terraform

    You can use the Terraform resource to create a new connection.

    To learn how to apply or remove a Terraform configuration, see Basic Terraform commands.

    To view a sample terraform template for connection creation, see sample template.

    When creating this connection by using Terraform, you must set the following variables in your Terraform configuration file:

    Parameter name Data type Required Description
    proxy_enabled BOOLEAN False Select this checkbox to configure a proxy server for the connection.

    Use the HTTP connection in an integration

    After you create the connection, it becomes available in both Apigee Integration and Application Integration. You can use the connection in an integration through the Connectors task.

    Get help from the Google Cloud community

    You can post your questions and discuss this connector in the Google Cloud community at Cloud Forums.

    What's next