# mulesoft HTTP Connector - Full Documentation --- product: HTTP Connector version: 1.10 keywords: http, https, request, requester --- # About HTTP Connector Migration > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP (HTTP Connector) contains the following key behavior differences: - The `http:listener-config` element has a new inner connection element `http:listener-connection`. - The `http:request-config` element has a new inner connection element `http:request-connection`. - The HTTP body parameter replaces the source parameter in the request and is incorporated into the listener’s response and error response. - The HTTP **Listener** source and HTTP **Request** operation return attributes. - The HTTP **Request** configuration has the **Enabled Cookie** parameter set to `true` (default). - HTTP parsing has been removed because DataWeave now manages special MIME types. Use DataWeave syntax to read and write payloads. - The HTTP **Load static resource** operation XML code `static-resource-handler` is renamed to `load-static-resource`. - To access HTTP listener and HTTP request attributes, the following DataWeave syntax replaces the Mule Expression Language (MEL) expressions for accessing past properties: `#[attributes.]` For expression mapping details, refer to the [HTTP Connector XML Reference](https://docs.mulesoft.com/http-connector/1.10/http-connector-xml-reference) documentation. - The following constructs are removed in Mule 4: - Request and response builders, `http:request-builder` and `http:response-builder` - Worker threading profile The request, response, and error-response replace the builders. Using DataWeave expressions eliminates the need for building parameters. ## See Also - [HTTP Connector XML Reference](https://docs.mulesoft.com/http-connector/1.10/http-connector-xml-reference) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation) --- product: HTTP Connector version: 1.11 keywords: http, https, request, requester --- # About HTTP Connector Migration > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP (HTTP Connector) contains the following key behavior differences: - The `http:listener-config` element has a new inner connection element `http:listener-connection`. - The `http:request-config` element has a new inner connection element `http:request-connection`. - The HTTP body parameter replaces the source parameter in the request and is incorporated into the listener’s response and error response. - The HTTP **Listener** source and HTTP **Request** operation return attributes. - The HTTP **Request** configuration has the **Enabled Cookie** parameter set to `true` (default). - HTTP parsing has been removed because DataWeave now manages special MIME types. Use DataWeave syntax to read and write payloads. - The HTTP **Load static resource** operation XML code `static-resource-handler` is renamed to `load-static-resource`. - To access HTTP listener and HTTP request attributes, the following DataWeave syntax replaces the Mule Expression Language (MEL) expressions for accessing past properties: `#[attributes.]` For expression mapping details, refer to the [HTTP Connector XML Reference](https://docs.mulesoft.com/http-connector/1.11/http-connector-xml-reference) documentation. - The following constructs are removed in Mule 4: - Request and response builders, `http:request-builder` and `http:response-builder` - Worker threading profile The request, response, and error-response replace the builders. Using DataWeave expressions eliminates the need for building parameters. ## See Also - [HTTP Connector XML Reference](https://docs.mulesoft.com/http-connector/1.11/http-connector-xml-reference) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation) --- product: HTTP Connector version: 1.12 is-latest-version: true keywords: http, https, request, requester --- # About HTTP Connector Migration > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP (HTTP Connector) contains the following key behavior differences: - The `http:listener-config` element has a new inner connection element `http:listener-connection`. - The `http:request-config` element has a new inner connection element `http:request-connection`. - The HTTP body parameter replaces the source parameter in the request and is incorporated into the listener’s response and error response. - The HTTP **Listener** source and HTTP **Request** operation return attributes. - The HTTP **Request** configuration has the **Enabled Cookie** parameter set to `true` (default). - HTTP parsing has been removed because DataWeave now manages special MIME types. Use DataWeave syntax to read and write payloads. - The HTTP **Load static resource** operation XML code `static-resource-handler` is renamed to `load-static-resource`. - To access HTTP listener and HTTP request attributes, the following DataWeave syntax replaces the Mule Expression Language (MEL) expressions for accessing past properties: `#[attributes.]` For expression mapping details, refer to the [HTTP Connector XML Reference](https://docs.mulesoft.com/http-connector/latest/http-connector-xml-reference) documentation. - The following constructs are removed in Mule 4: - Request and response builders, `http:request-builder` and `http:response-builder` - Worker threading profile The request, response, and error-response replace the builders. Using DataWeave expressions eliminates the need for building parameters. ## See Also - [HTTP Connector XML Reference](https://docs.mulesoft.com/http-connector/latest/http-connector-xml-reference) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation) --- product: HTTP Connector version: 1.10 --- # Configure HTTP Listener Source > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Connector for HTTP (HTTP Connector) **Listener** source enables you to set up an HTTP server and trigger flows when receiving HTTP requests. You can choose what methods the source accepts, such as `GET` and `POST` or a list of methods. You can also choose in which path to receive HTTP requests, thereby allowing requests to be routed through different flows. When the HTTP **Listener** source receives an HTTP request, the source triggers the flow by using the request data. The HTTP body is set as the payload, and the remaining HTTP data is set as attributes, such as headers and query parameters. When the flow finishes its execution, the HTTP **Listener** source sends an HTTP response based on whether the flow execution was successful or not, which returns different status codes. You can also customize how the source generates HTTP responses in the connector source configuration. ## Configure HTTP Listener Connection To use an HTTP **Listener** source, you must configure a connection with these settings: - **Host** Indicates where the requests are received. Also, the host can be a hostname, such as `localhost`, `www.mulesoft.com`, or an IP, for example `127.0.0.1`, `::1`. - **Port** Indicates where the requests are received. - **Protocol** Indicates the protocol for communication, either HTTP for plain connections or HTTPS for TLS secure connections. To enable secure connections through HTTPS, you must define a TLS context in the connection and provide: - A keystore for the server - A truststore if you need two-way authentication To learn about TLS configuration, refer to the [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) documentation. Additionally, you can configure the **Base path** field that applies to all HTTP **Listener** sources using the configuration. The following example shows how to configure the HTTP **Listener** connection in Studio: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/path`. ![HTTP Listener configuration window and Path field set to /test](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-1.png) 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Listener** in the app. 5. Set **Host** to `0.0.0.0` and **Port** to `8081`. ![HTTP Listener global configuration window with Host field set to 0.0.0.0 and Port field to 8081](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-2.png) 6. Click the **TLS** tab. 7. Set **TLS configuration** to **Edit inline**. 8. In the **Trust Store Configuration** section, set **Path** to `keystore.jks` and **Password** to `MyP455W0rD`. ![Trust Store Configuration window with Path field set to keystore.jks and Password field to MyP455W0rD](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-3.png) 9. Click **OK**. In the **Configuration XML** editor, the `host`, `port`, `path` and `trust-store` configurations look like these: ```xml ``` To configure the **Base path** field for the source: 1. In the HTTP **Listener** configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to configure a global element. 2. In **HTTP Listener config**, set **Base path** to `api/v1`. ![HTTP Listener global configuration window with Base path field set to api/v1](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-4.png) 3. Click **OK**. In the **Configuration XML** editor, the `basePath` configuration looks like this: ```xml ``` > [!NOTE] If you deploy a project to CloudHub, set **Host** to **0.0.0.0** so the connection listens > to all the interfaces of the machine. > If you deploy locally for testing purposes, set **Host** to **localhost** to receive only requests > that are generated locally. The app is not vulnerable to external threats. You can also configure advanced settings that can define whether the connections are persistent and, if they are not, the timeout the connections will have. ## Configure Paths Because an HTTP **Listener** source acts as an event trigger within flows, it must reference the configuration to use and the path where the source listens for HTTP requests. Paths can be either static, which requires exact matches, or feature placeholders. Placeholders can be: - Wildcards (`*`) Match anything they are compared to. Wildcards at the end of a path can help provide better error messages by capturing requests to unmanaged resources. - Parameters (`{param}`) Match not only anything they are compared to but also capture those values on a URI parameters map. The following examples show different path configurations for three HTTP **Listener** sources, the paths are defined in the **Path** field and the **Base path** field is set to `api/v1`: - `account/mulesoft/main-contact` Matches only the exact path request `http://awesome-company.com/api/v1/account/mulesoft/main-contact`. - `account/{accountId}/main-contact` Matches all path requests structured similarly, such as `http://awesome-company.com/api/v1/account/salesforce/main-contact`, and saves `salesforce` as the value of `accountId`. - `account/{accountId}/*` Matches all path requests different from `main-contact`, such as `http://awesome-company.com/api/v1/account/mulesoft/users`, and saves `mulesoft` as the value of `accountId`. When the Mule app has multiple HTTP **Listener** sources, HTTP requests are always routed to the most specific source. In the previous examples, the first HTTP **Listener** source receives a request with `accountId: mulesoft` and suffix `main-contact`, and the second source receives any different `accountId` value. ## Configure Allowed Methods HTTP requests are routed based on the HTTP method received. By default, an HTTP **Listener** source supports all methods, but you can restrict the available methods or even configure custom ones. The following example shows how to configure the **Allowed methods** field in Studio: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. In the HTTP **Listener** source configuration screen, click the **Advanced** tab. 4. Set **Allowed methods** to `GET`. ![HTTP Listener configuration window and Allowed methods field set to GET](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-5.png) In the **Configuration XML** editor, the `allowedMethods` configuration looks like this: ```xml ``` When a Mule app has multiple HTTP **Listener** sources, requests are routed to the first source matching the method, so default sources should always be defined last. The following example shows different HTTP **Listener** source configurations, in which the **Allowed method** field is set to `GET`, `POST` and `PUT`. These different configurations cause HTTP requests to be routed to different flows, enabling you to specify and restrict user access to your data: ```xml ``` ## Configure Response Streaming Mode When HTTP Connector manages response bodies, the connector considers the type of data to send and uses _chunked_ encoding when the body size is not clear. This causes streams with no size information. To control this behavior, configure the **Response streaming mode** field to any of these options: - **AUTO (default)** Uses `Content-Length` encoding if a size is defined for the body, otherwise uses `Transfer-Encoding: chunked`. - **ALWAYS** Uses `Transfer-Encoding: chunked` regardless of any size data present. - **NEVER** Uses `Content-Length` encoding, consuming streams if necessary to determine the data size. The following example shows how to configure the **Response streaming mode** field in Studio. In the example, the main contact data for an account always returns `Content-Length` encoding: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `account/{accountId}/main-contact`. 4. In the HTTP **Listener** source configuration screen, click the **Advanced** tab. 5. Set **Allowed methods** to `GET`. 6. Set **Response streaming mode** to `NEVER`. ![HTTP Listener configuration window with Allowed methods field set to GET and Response streaming mode field set to NEVER](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-6.png) In the **Configuration XML** editor, the `allowedMethods` and `responseStreamingMode` configurations look like this: ```xml ``` ## Configure Read Timeout The read timeout means that if the HTTP **Listener** source doesn’t read data after read timeout milliseconds, the connector raises a timeout error. Use the **Read timeout** field to prevent a client from sending an HTTP request such as: ```JSON POST /test HTTP/1.1 Host: localhost:8081 Content-Length: 10000 2 ``` Notice that you don’t specify a read timeout, the **Listener** source waits for data for ever, and the connection is not released. The **Read timeout** field defaults to a value of 30000, and the time unit in milliseconds. To configure the read timeout for the source, in the HTTP **Listener** configuration window, set the **Read timeout** field to the desired value: ![HTTP Listener configuration window with Read timeout field set to 30000](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-7.png) In the **Configuration XML** editor, the `readTimeout` configuration looks like this: ```xml ``` ## Configure Reject Invalid Transfer Encoding Headers Based on [RFC7230](https://www.rfc-editor.org/rfc/rfc7230.html) and [RFC2616](https://www.rfc-editor.org/rfc/rfc2616.html) valid Transfer-Encoding headers are `chunked`, `deflate`, `compress`, `identity`, and `gzip`. These headers are not case-sensitive. To reject requests with invalid Transfer-Encoding headers, in the HTTP **Listener** configuration window, select the **Reject invalid transfer encoding** checkbox: ![HTTP Listener configuration window with Reject invalid transfer encoding field selected](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-8.png) In the **Configuration XML** editor, the `rejectInvalidTransferEncoding` configuration looks like this: ```xml ``` ## Receiving HTTP Requests When an HTTP **Listener** source receives an HTTP request, the data from the HTTP request line includes the method, request path, query, URI parameters, and headers as attributes. The body sets the payload, and the `Content-Type` header sets the MIME type, which enables other components to inspect the payload MIME type. For example, DataWeave works with an HTTP payload without requiring any input information. You can refer to attributes, such as headers, query parameters, and so on using the `HttpRequestAttributes` syntax. When you configure an HTTP request, do not set the `Content-Type` header. Mule runtime engine automatically infers the header from the message payload. If you set the `Content-Type` header for payload formatted as `multipart/form-data`, the HTTP request fails with a 400 error status. Additionally, if an HTTP request contains any of these headers: `X-Correlation-ID` or `MULE_CORRELATION_ID`, these set the message’s correlation ID for traceability. ### HTTP Request Example The following example shows an HTTP request: ```JSON POST api/v1/account/salesforce/main-contact?overwrite=true¬ify=jane.doe¬ify=admin HTTP/1.1 Host: localhost:8081 Content-Type: application/json Content-Length: 166 X-Correlation-ID: 9cf32672-4f0b-4e8b-b988-40c13aae85b4 { "name": "John", "surname": "Doe", "role": "Senior Vice President", "organization": "Marketing", "phone": 701222369, "email": "john.doe@salesforce.com" } ``` The message’s correlation ID is `9cf32672-4f0b-4e8b-b988-40c13aae85b4`. The payload is in JSON format: ```JSON { "name": "John", "surname": "Doe", "role": "Senior Vice President", "organization": "Marketing", "phone": 701222369, "email": "john.doe@salesforce.com" } ``` The attributes include: - method: `POST` - listenerPath: `api/v1/account/{accountId}/main-contact` - requestPath: `api/v1/account/salesforce/main-contact` - relativePath: `account/salesforce/main-contact` - queryParams: a multimap with entries `overwrite=true`, `notify=jane.doe`, and `notify=admin` - uriParams: a map with entry `accountId ⇒ salesforce` - headers: a multimap with entries `Host=localhost:8081`, `Content-Type=application/json`, `Content-Length=166`, and `X-Correlation-ID=9cf32672-4f0b-4e8b-b988-40c13aae85b4` A DataWeave expression such as `#[payload.name ' ' payload.surname]` returns `John Doe` because DataWeave correctly interprets the JSON data. A DataWeave expression such as `#['Received a ' attributes.method ' request for account ' attributes.uriParams.accountId '. The following users are notified: ' ++ (attributes.queryParams.*notify joinBy ', ')]` returns `Received a POST request for account salesforce. The following users are notified: admin, jane.doe`. To access HTTP Listener attributes, use DataWeave syntax as shown in the following table:
HTTP objectMule runtime engine 4.x

Method

#[attributes.method]

Path

#[attributes.listenerPath]

Relative Path

#[attributes.relativePath]

Request URI

#[attributes.requestUri]

Query String

#[attributes.queryString]

Query Parameters

#[attributes.queryParams]

URI Parameters

#[attributes.uriParams]

Version

#[attributes.version]

Scheme

#[attributes.scheme]

Headers

#[attributes.headers]

Remote Address

#[attributes.remoteAddress]

Client Certificate

#[attributes.clientCertificate]

> [!NOTE] _Multimaps_ are similar to maps except they allow several values for a given key. > Multimaps return the first value when using a single-value selector (`.`), but they allow to > retrieve all values when using the multiple-value selector (`.*`). ### HTTP Request Mapping to Mule Event Example The following diagram shows an example of an HTTP request and its mapping to a Mule event. ![Map of HTTP Request to Mule Event](/mulesoft/current/en-us/http-connector/1.10/_images/request-mule-msg-map.png) Use [DataWeave](https://docs.mulesoft.com/dataweave/latest/) language to access the HTTP request data attributes and payload. ### HTTP Request Multipart Form-Data Example The following example shows an HTTP request of an HTML form received by an HTTP **Listener** source. Additionally, the example shows how to use DataWeave expressions to read `multipart/form-data` content. Based on the following HTML form: ```xml
How would you like to identify the logo?
Which is the logo file?
What is the main color in the logo?
``` The HTTP **Listener** source receives the following `multipart/form-data` HTTP request: ```text POST /api/v1/account/mulesoft/logo HTTP/1.1 Content-Type: multipart/form-data; boundary=489691234097965980223899 Host: localhost:8081 content-length: 34332 --489691234097965980223899 Content-Disposition: form-data; name="name" Corporate Logo --489691234097965980223899 Content-Disposition: form-data; name="logo"; filename="MuleSoft_logo.png" Content-Type: image/png .PNG . ... IHDR.......L......~..... pHYs...#...#.x.?v.. .IDATx....q.W.6.....~".N....t....t..#.....LD0T.CF0b..:.3......Q..@...q]U*y\c.... ....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`% .$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....^6.......|..P.....IEND.B`. --489691234097965980223899 Content-Disposition: form-data; name="color" blue --489691234097965980223899-- ``` You can use DataWeave expressions to access and read each HTTP request parameter data through the `parts` object, either by name or item number. For example, to access the second part of the HTTP request that contains the `Corporate Logo` parameters data, you can use `payload.parts.logo` or `payload.parts[1]`. The latter is useful when a name is not provided. Within each part, you can access its content and headers. For example, `payload.parts.color.content` returns `blue`, while `payload.parts.logo.headers.'Content-Type'` returns `application/png`. You can also access the filename of a part. For example, the `Content-Disposition` header is parsed to allow an expression like `payload.parts.logo.headers.'Content-Disposition'.filename`, which in this case returns `MuleSoft_logo.png`. Refer to the [Formats Supported by DataWeave](https://docs.mulesoft.com/dataweave/latest/dataweave-formats) documentation to learn about reading and writing multipart content. ## Sending HTTP Responses After the triggered flow finishes its execution, the HTTP **Listener** source sends either of the following default results: - Successful execution: an HTTP response with 200 status code and the message payload as the body - Unsuccessful execution: an HTTP error response with 500 status code with the flow error’s description as the body In the HTTP **Listener** source configuration, you can customize HTTP responses by providing the following parameters: - **Body** - **Headers** - **Status code** - **Reason phrase** Note that you can use DataWeave to generate content for each parameter, and variables to propagate data from the flow. ### Create Sending HTTP Responses Mule App Example The following example shows how to configure HTTP responses for the HTTP **Listener** source in Studio. The example is a Mule app flow where an endpoint stores logos for an account: - When storage is successful, an HTTP regular response returns the status code `201`, the reason phrase `Created`, and the body `Corporate Logo has been stored as a MuleSoft logo`. - When storage fails, an HTTP error response returns a status code defined through the `errorCode` variable (if available) or `500` by default. - The custom header returns `X-Time`. - The body returns `Corporate Logo could not be stored`. - If there is a `CONNECTIVITY` error storing the logo, the returned status code is `504`, while any other errors result in a `500` status code. While a reason phrase is not defined for error responses, HTTP Connector attempts to define a reason phrase based on the status code. Thereby, a `Gateway Timeout` or `Internal Server Error` error can be returned for the previous explained HTTP responses scenarios. To test the Mule app you need a table named `logo` with two columns: `(accountId,logoName)`. You can use Mule to create the table or create it some other way. For example, the following XML code shows how to create the table using the Database Connector **Execute script** operation: ```xml ``` To create the Mule app in Studio, follow these steps: 1. In the **Mule Palette** view, select **HTTP>Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/account/{accountId}/logo`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Listener** in the app. 5. Set **Host** to `0.0.0.0` and **Port** to `8081`. 6. Click **OK**. 7. In the HTTP **Listener** configuration screen, click the **Responses** tab. 8. In the **Response** section, set these values: - **Body** : `output text/plain --- vars.logoName ' has been stored as a ' vars.accountId ++ ' logo.'` - **Status code** : `201` - **Reason phrase** : `Created` 9. In the **Error Response** section, set these values: - **Body** : `vars.logoName ++ ' could not be stored.'` - **Headers** : ```DataWeave output application/java --- { "X-Time" : "50s" // 4 } ``` - **Status code** : `vars.errorCode default 500`. ![HTTP Listener Responses configuration window with Body](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-9.png) 10. Drag a **Set Variable** component to the right of HTTP **Listener**. 11. Set **Name** to `logoName`. 12. Set **Value** to the expression `payload.parts.name.content`. 13. Drag another **Set Variable** component to the right of first **Set Variable** component. 14. Set **Name** to `accountId`. 15. Set **Value** to the expression `attributes.uriParams.accountId`. 16. Drag a Database **Insert** operation to the right of the second **Set Variable** component. 17. Click the plus sign (**+**) next to the **Connector configuration** field to configure the database connection. For further information about how to configure a database connection, refer to the [configure a database connection](https://docs.mulesoft.com/db-connector/latest/database-connector-connection) documentation. 18. In the **Insert** operation configuration screen, set **SQL Query Text** to `INSERT INTO logo (accountId,logoName) VALUES (:accountId, :logoName`). 19. Set **Input parameters** to the expression `{'accountId': vars.accountId as String, 'logoName': vars.logoName as String}`. 20. Drag an **On Error Propagate** component in the **Error handling** section of the flow. 21. Set **Type** to `DB:CONNECTIVITY`. 22. Drag a **Set Variable** component into the **On Error Propagate** component. 23. Set **Name** to `errorCode`. 24. Set **Value** to `504`. 25. Save and run your Mule app. 26. Send the following CURL command: `curl -v -F 'data=@/path/to/MuleSoft_logo.svg' -F name=mulesoftlogo [http://localhost:8081/account/muley/logo](http://localhost:8081/account/muley/logo)`. Note that the complete payload has been hidden because the content length is too big to be human readable: ```json * Trying 127.0.0.1... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 8081 (#0) > POST /account/muley/logo HTTP/1.1 > Host: localhost:8081 > User-Agent: curl/7.64.1 > Accept: */* > Content-Length: 5313 > Content-Type: multipart/form-data; boundary=------------------------d96e85d23101a1c3 > Expect: 100-continue > < HTTP/1.1 100 Continue * We are completely uploaded and fine < HTTP/1.1 201 Created < Content-Type: text/plain; charset=UTF-8 < Content-Length: 45 < Date: Tue, 18 Jan 2022 20:30:20 GMT < * Connection #0 to host localhost left intact mulesoftlogo has been stored as a muley logo.* Closing connection 0 ``` ### XML for Sending HTTP Responses Mule App Example Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation) - [HTTP Connector Troubleshooting Guide](https://docs.mulesoft.com/http-connector/1.10/http-troubleshooting) - [DataWeave Formats](https://docs.mulesoft.com/dataweave/latest/dataweave-formats) - [TLS Configuration](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) - [HTTP Request Attributes Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation#HttpRequestAttributes) - [HTTP Response Attributes Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation#HttpResponseAttributes) --- product: HTTP Connector version: 1.11 --- # Configure HTTP Listener Source > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Connector for HTTP (HTTP Connector) **Listener** source enables you to set up an HTTP server and trigger flows when receiving HTTP requests. You can choose what methods the source accepts, such as `GET` and `POST` or a list of methods. You can also choose in which path to receive HTTP requests, thereby allowing requests to be routed through different flows. When the HTTP **Listener** source receives an HTTP request, the source triggers the flow by using the request data. The HTTP body is set as the payload, and the remaining HTTP data is set as attributes, such as headers and query parameters. When the flow finishes its execution, the HTTP **Listener** source sends an HTTP response based on whether the flow execution was successful or not, which returns different status codes. You can also customize how the source generates HTTP responses in the connector source configuration. ## Configure HTTP Listener Connection To use an HTTP **Listener** source, you must configure a connection with these settings: - **Host** Indicates where the requests are received. Also, the host can be a hostname, such as `localhost`, `www.mulesoft.com`, or an IP, for example `127.0.0.1`, `::1`. - **Port** Indicates where the requests are received. - **Protocol** Indicates the protocol for communication, either HTTP for plain connections or HTTPS for TLS secure connections. To enable secure connections through HTTPS, you must define a TLS context in the connection and provide: - A keystore for the server - A truststore if you need two-way authentication To learn about TLS configuration, refer to the [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) documentation. Additionally, you can configure the **Base path** field that applies to all HTTP **Listener** sources using the configuration. The following example shows how to configure the HTTP **Listener** connection in Studio: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/path`. ![HTTP Listener configuration window and Path field set to /test](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-1.png) 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Listener** in the app. 5. Set **Host** to `0.0.0.0` and **Port** to `8081`. ![HTTP Listener global configuration window with Host field set to 0.0.0.0 and Port field to 8081](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-2.png) 6. Click the **TLS** tab. 7. Set **TLS configuration** to **Edit inline**. 8. In the **Trust Store Configuration** section, set **Path** to `keystore.jks` and **Password** to `MyP455W0rD`. ![Trust Store Configuration window with Path field set to keystore.jks and Password field to MyP455W0rD](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-3.png) 9. Click **OK**. In the **Configuration XML** editor, the `host`, `port`, `path` and `trust-store` configurations look like these: ```xml ``` To configure the **Base path** field for the source: 1. In the HTTP **Listener** configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to configure a global element. 2. In **HTTP Listener config**, set **Base path** to `api/v1`. ![HTTP Listener global configuration window with Base path field set to api/v1](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-4.png) 3. Click **OK**. In the **Configuration XML** editor, the `basePath` configuration looks like this: ```xml ``` > [!NOTE] If you deploy a project to CloudHub, set **Host** to **0.0.0.0** so the connection listens > to all the interfaces of the machine. > If you deploy locally for testing purposes, set **Host** to **localhost** to receive only requests > that are generated locally. The app is not vulnerable to external threats. You can also configure advanced settings that can define whether the connections are persistent and, if they are not, the timeout the connections will have. ## Configure Paths Because an HTTP **Listener** source acts as an event trigger within flows, it must reference the configuration to use and the path where the source listens for HTTP requests. Paths can be either static, which requires exact matches, or feature placeholders. Placeholders can be: - Wildcards (`*`) Match anything they are compared to. Wildcards at the end of a path can help provide better error messages by capturing requests to unmanaged resources. - Parameters (`{param}`) Match not only anything they are compared to but also capture those values on a URI parameters map. The following examples show different path configurations for three HTTP **Listener** sources, the paths are defined in the **Path** field and the **Base path** field is set to `api/v1`: - `account/mulesoft/main-contact` Matches only the exact path request `http://awesome-company.com/api/v1/account/mulesoft/main-contact`. - `account/{accountId}/main-contact` Matches all path requests structured similarly, such as `http://awesome-company.com/api/v1/account/salesforce/main-contact`, and saves `salesforce` as the value of `accountId`. - `account/{accountId}/*` Matches all path requests different from `main-contact`, such as `http://awesome-company.com/api/v1/account/mulesoft/users`, and saves `mulesoft` as the value of `accountId`. When the Mule app has multiple HTTP **Listener** sources, HTTP requests are always routed to the most specific source. In the previous examples, the first HTTP **Listener** source receives a request with `accountId: mulesoft` and suffix `main-contact`, and the second source receives any different `accountId` value. ## Configure Allowed Methods HTTP requests are routed based on the HTTP method received. By default, an HTTP **Listener** source supports all methods, but you can restrict the available methods or even configure custom ones. The following example shows how to configure the **Allowed methods** field in Studio: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. In the HTTP **Listener** source configuration screen, click the **Advanced** tab. 4. Set **Allowed methods** to `GET`. ![HTTP Listener configuration window and Allowed methods field set to GET](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-5.png) In the **Configuration XML** editor, the `allowedMethods` configuration looks like this: ```xml ``` When a Mule app has multiple HTTP **Listener** sources, requests are routed to the first source matching the method, so default sources should always be defined last. The following example shows different HTTP **Listener** source configurations, in which the **Allowed method** field is set to `GET`, `POST` and `PUT`. These different configurations cause HTTP requests to be routed to different flows, enabling you to specify and restrict user access to your data: ```xml ``` ## Configure Response Streaming Mode When HTTP Connector manages response bodies, the connector considers the type of data to send and uses _chunked_ encoding when the body size is not clear. This causes streams with no size information. To control this behavior, configure the **Response streaming mode** field to any of these options: - **AUTO (default)** Uses `Content-Length` encoding if a size is defined for the body, otherwise uses `Transfer-Encoding: chunked`. - **ALWAYS** Uses `Transfer-Encoding: chunked` regardless of any size data present. - **NEVER** Uses `Content-Length` encoding, consuming streams if necessary to determine the data size. The following example shows how to configure the **Response streaming mode** field in Studio. In the example, the main contact data for an account always returns `Content-Length` encoding: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `account/{accountId}/main-contact`. 4. In the HTTP **Listener** source configuration screen, click the **Advanced** tab. 5. Set **Allowed methods** to `GET`. 6. Set **Response streaming mode** to `NEVER`. ![HTTP Listener configuration window with Allowed methods field set to GET and Response streaming mode field set to NEVER](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-6.png) In the **Configuration XML** editor, the `allowedMethods` and `responseStreamingMode` configurations look like this: ```xml ``` ## Configure Read Timeout The read timeout means that if the HTTP **Listener** source doesn’t read data after read timeout milliseconds, the connector raises a timeout error. Use the **Read timeout** field to prevent a client from sending an HTTP request such as: ```JSON POST /test HTTP/1.1 Host: localhost:8081 Content-Length: 10000 2 ``` Notice that you don’t specify a read timeout, the **Listener** source waits for data for ever, and the connection is not released. The **Read timeout** field defaults to a value of 30000, and the time unit in milliseconds. To configure the read timeout for the source, in the HTTP **Listener** configuration window, set the **Read timeout** field to the desired value: ![HTTP Listener configuration window with Read timeout field set to 30000](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-7.png) In the **Configuration XML** editor, the `readTimeout` configuration looks like this: ```xml ``` ## Configure Reject Invalid Transfer Encoding Headers Based on [RFC7230](https://www.rfc-editor.org/rfc/rfc7230.html) and [RFC2616](https://www.rfc-editor.org/rfc/rfc2616.html) valid Transfer-Encoding headers are `chunked`, `deflate`, `compress`, `identity`, and `gzip`. These headers are not case-sensitive. To reject requests with invalid Transfer-Encoding headers, in the HTTP **Listener** configuration window, select the **Reject invalid transfer encoding** checkbox: ![HTTP Listener configuration window with Reject invalid transfer encoding field selected](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-8.png) In the **Configuration XML** editor, the `rejectInvalidTransferEncoding` configuration looks like this: ```xml ``` ## Receiving HTTP Requests When an HTTP **Listener** source receives an HTTP request, the data from the HTTP request line includes the method, request path, query, URI parameters, and headers as attributes. The body sets the payload, and the `Content-Type` header sets the MIME type, which enables other components to inspect the payload MIME type. For example, DataWeave works with an HTTP payload without requiring any input information. You can refer to attributes, such as headers, query parameters, and so on using the `HttpRequestAttributes` syntax. When you configure an HTTP request, do not set the `Content-Type` header. Mule runtime engine automatically infers the header from the message payload. If you set the `Content-Type` header for payload formatted as `multipart/form-data`, the HTTP request fails with a 400 error status. Additionally, if an HTTP request contains any of these headers: `X-Correlation-ID` or `MULE_CORRELATION_ID`, these set the message’s correlation ID for traceability. ### HTTP Request Example The following example shows an HTTP request: ```JSON POST api/v1/account/salesforce/main-contact?overwrite=true¬ify=jane.doe¬ify=admin HTTP/1.1 Host: localhost:8081 Content-Type: application/json Content-Length: 166 X-Correlation-ID: 9cf32672-4f0b-4e8b-b988-40c13aae85b4 { "name": "John", "surname": "Doe", "role": "Senior Vice President", "organization": "Marketing", "phone": 701222369, "email": "john.doe@salesforce.com" } ``` The message’s correlation ID is `9cf32672-4f0b-4e8b-b988-40c13aae85b4`. The payload is in JSON format: ```JSON { "name": "John", "surname": "Doe", "role": "Senior Vice President", "organization": "Marketing", "phone": 701222369, "email": "john.doe@salesforce.com" } ``` The attributes include: - method: `POST` - listenerPath: `api/v1/account/{accountId}/main-contact` - requestPath: `api/v1/account/salesforce/main-contact` - relativePath: `account/salesforce/main-contact` - queryParams: a multimap with entries `overwrite=true`, `notify=jane.doe`, and `notify=admin` - uriParams: a map with entry `accountId ⇒ salesforce` - headers: a multimap with entries `Host=localhost:8081`, `Content-Type=application/json`, `Content-Length=166`, and `X-Correlation-ID=9cf32672-4f0b-4e8b-b988-40c13aae85b4` A DataWeave expression such as `#[payload.name ' ' payload.surname]` returns `John Doe` because DataWeave correctly interprets the JSON data. A DataWeave expression such as `#['Received a ' attributes.method ' request for account ' attributes.uriParams.accountId '. The following users are notified: ' ++ (attributes.queryParams.*notify joinBy ', ')]` returns `Received a POST request for account salesforce. The following users are notified: admin, jane.doe`. To access HTTP Listener attributes, use DataWeave syntax as shown in the following table:
HTTP objectMule runtime engine 4.x

Method

#[attributes.method]

Path

#[attributes.listenerPath]

Relative Path

#[attributes.relativePath]

Request URI

#[attributes.requestUri]

Query String

#[attributes.queryString]

Query Parameters

#[attributes.queryParams]

URI Parameters

#[attributes.uriParams]

Version

#[attributes.version]

Scheme

#[attributes.scheme]

Headers

#[attributes.headers]

Remote Address

#[attributes.remoteAddress]

Client Certificate

#[attributes.clientCertificate]

> [!NOTE] _Multimaps_ are similar to maps except they allow several values for a given key. > Multimaps return the first value when using a single-value selector (`.`), but they allow to > retrieve all values when using the multiple-value selector (`.*`). ### HTTP Request Mapping to Mule Event Example The following diagram shows an example of an HTTP request and its mapping to a Mule event. ![Map of HTTP Request to Mule Event](/mulesoft/current/en-us/http-connector/1.11/_images/request-mule-msg-map.png) Use [DataWeave](https://docs.mulesoft.com/dataweave/latest/) language to access the HTTP request data attributes and payload. ### HTTP Request Multipart Form-Data Example The following example shows an HTTP request of an HTML form received by an HTTP **Listener** source. Additionally, the example shows how to use DataWeave expressions to read `multipart/form-data` content. Based on the following HTML form: ```xml
How would you like to identify the logo?
Which is the logo file?
What is the main color in the logo?
``` The HTTP **Listener** source receives the following `multipart/form-data` HTTP request: ```text POST /api/v1/account/mulesoft/logo HTTP/1.1 Content-Type: multipart/form-data; boundary=489691234097965980223899 Host: localhost:8081 content-length: 34332 --489691234097965980223899 Content-Disposition: form-data; name="name" Corporate Logo --489691234097965980223899 Content-Disposition: form-data; name="logo"; filename="MuleSoft_logo.png" Content-Type: image/png .PNG . ... IHDR.......L......~..... pHYs...#...#.x.?v.. .IDATx....q.W.6.....~".N....t....t..#.....LD0T.CF0b..:.3......Q..@...q]U*y\c.... ....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`% .$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....^6.......|..P.....IEND.B`. --489691234097965980223899 Content-Disposition: form-data; name="color" blue --489691234097965980223899-- ``` You can use DataWeave expressions to access and read each HTTP request parameter data through the `parts` object, either by name or item number. For example, to access the second part of the HTTP request that contains the `Corporate Logo` parameters data, you can use `payload.parts.logo` or `payload.parts[1]`. The latter is useful when a name is not provided. Within each part, you can access its content and headers. For example, `payload.parts.color.content` returns `blue`, while `payload.parts.logo.headers.'Content-Type'` returns `application/png`. You can also access the filename of a part. For example, the `Content-Disposition` header is parsed to allow an expression like `payload.parts.logo.headers.'Content-Disposition'.filename`, which in this case returns `MuleSoft_logo.png`. Refer to the [Formats Supported by DataWeave](https://docs.mulesoft.com/dataweave/latest/dataweave-formats) documentation to learn about reading and writing multipart content. ## Sending HTTP Responses After the triggered flow finishes its execution, the HTTP **Listener** source sends either of the following default results: - Successful execution: an HTTP response with 200 status code and the message payload as the body - Unsuccessful execution: an HTTP error response with 500 status code with the flow error’s description as the body In the HTTP **Listener** source configuration, you can customize HTTP responses by providing the following parameters: - **Body** - **Headers** - **Status code** - **Reason phrase** Note that you can use DataWeave to generate content for each parameter, and variables to propagate data from the flow. ### Create Sending HTTP Responses Mule App Example The following example shows how to configure HTTP responses for the HTTP **Listener** source in Studio. The example is a Mule app flow where an endpoint stores logos for an account: - When storage is successful, an HTTP regular response returns the status code `201`, the reason phrase `Created`, and the body `Corporate Logo has been stored as a MuleSoft logo`. - When storage fails, an HTTP error response returns a status code defined through the `errorCode` variable (if available) or `500` by default. - The custom header returns `X-Time`. - The body returns `Corporate Logo could not be stored`. - If there is a `CONNECTIVITY` error storing the logo, the returned status code is `504`, while any other errors result in a `500` status code. While a reason phrase is not defined for error responses, HTTP Connector attempts to define a reason phrase based on the status code. Thereby, a `Gateway Timeout` or `Internal Server Error` error can be returned for the previous explained HTTP responses scenarios. To test the Mule app you need a table named `logo` with two columns: `(accountId,logoName)`. You can use Mule to create the table or create it some other way. For example, the following XML code shows how to create the table using the Database Connector **Execute script** operation: ```xml ``` To create the Mule app in Studio, follow these steps: 1. In the **Mule Palette** view, select **HTTP>Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/account/{accountId}/logo`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Listener** in the app. 5. Set **Host** to `0.0.0.0` and **Port** to `8081`. 6. Click **OK**. 7. In the HTTP **Listener** configuration screen, click the **Responses** tab. 8. In the **Response** section, set these values: - **Body** : `output text/plain --- vars.logoName ' has been stored as a ' vars.accountId ++ ' logo.'` - **Status code** : `201` - **Reason phrase** : `Created` 9. In the **Error Response** section, set these values: - **Body** : `vars.logoName ++ ' could not be stored.'` - **Headers** : ```DataWeave output application/java --- { "X-Time" : "50s" // 4 } ``` - **Status code** : `vars.errorCode default 500`. ![HTTP Listener Responses configuration window with Body](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-9.png) 10. Drag a **Set Variable** component to the right of HTTP **Listener**. 11. Set **Name** to `logoName`. 12. Set **Value** to the expression `payload.parts.name.content`. 13. Drag another **Set Variable** component to the right of first **Set Variable** component. 14. Set **Name** to `accountId`. 15. Set **Value** to the expression `attributes.uriParams.accountId`. 16. Drag a Database **Insert** operation to the right of the second **Set Variable** component. 17. Click the plus sign (**+**) next to the **Connector configuration** field to configure the database connection. For further information about how to configure a database connection, refer to the [configure a database connection](https://docs.mulesoft.com/db-connector/latest/database-connector-connection) documentation. 18. In the **Insert** operation configuration screen, set **SQL Query Text** to `INSERT INTO logo (accountId,logoName) VALUES (:accountId, :logoName`). 19. Set **Input parameters** to the expression `{'accountId': vars.accountId as String, 'logoName': vars.logoName as String}`. 20. Drag an **On Error Propagate** component in the **Error handling** section of the flow. 21. Set **Type** to `DB:CONNECTIVITY`. 22. Drag a **Set Variable** component into the **On Error Propagate** component. 23. Set **Name** to `errorCode`. 24. Set **Value** to `504`. 25. Save and run your Mule app. 26. Send the following CURL command: `curl -v -F 'data=@/path/to/MuleSoft_logo.svg' -F name=mulesoftlogo [http://localhost:8081/account/muley/logo](http://localhost:8081/account/muley/logo)`. Note that the complete payload has been hidden because the content length is too big to be human readable: ```json * Trying 127.0.0.1... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 8081 (#0) > POST /account/muley/logo HTTP/1.1 > Host: localhost:8081 > User-Agent: curl/7.64.1 > Accept: */* > Content-Length: 5313 > Content-Type: multipart/form-data; boundary=------------------------d96e85d23101a1c3 > Expect: 100-continue > < HTTP/1.1 100 Continue * We are completely uploaded and fine < HTTP/1.1 201 Created < Content-Type: text/plain; charset=UTF-8 < Content-Length: 45 < Date: Tue, 18 Jan 2022 20:30:20 GMT < * Connection #0 to host localhost left intact mulesoftlogo has been stored as a muley logo.* Closing connection 0 ``` ### XML for Sending HTTP Responses Mule App Example Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation) - [HTTP Connector Troubleshooting Guide](https://docs.mulesoft.com/http-connector/1.11/http-troubleshooting) - [DataWeave Formats](https://docs.mulesoft.com/dataweave/latest/dataweave-formats) - [TLS Configuration](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) - [HTTP Request Attributes Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation#HttpRequestAttributes) - [HTTP Response Attributes Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation#HttpResponseAttributes) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Configure HTTP Listener Source > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Connector for HTTP (HTTP Connector) **Listener** source enables you to set up an HTTP server and trigger flows when receiving HTTP requests. You can choose what methods the source accepts, such as `GET` and `POST` or a list of methods. You can also choose in which path to receive HTTP requests, thereby allowing requests to be routed through different flows. When the HTTP **Listener** source receives an HTTP request, the source triggers the flow by using the request data. The HTTP body is set as the payload, and the remaining HTTP data is set as attributes, such as headers and query parameters. When the flow finishes its execution, the HTTP **Listener** source sends an HTTP response based on whether the flow execution was successful or not, which returns different status codes. You can also customize how the source generates HTTP responses in the connector source configuration. ## Configure HTTP Listener Connection To use an HTTP **Listener** source, you must configure a connection with these settings: - **Host** Indicates where the requests are received. Also, the host can be a hostname, such as `localhost`, `www.mulesoft.com`, or an IP, for example `127.0.0.1`, `::1`. - **Port** Indicates where the requests are received. - **Protocol** Indicates the protocol for communication, either HTTP for plain connections or HTTPS for TLS secure connections. To enable secure connections through HTTPS, you must define a TLS context in the connection and provide: - A keystore for the server - A truststore if you need two-way authentication To learn about TLS configuration, refer to the [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) documentation. Additionally, you can configure the **Base path** field that applies to all HTTP **Listener** sources using the configuration. The following example shows how to configure the HTTP **Listener** connection in Studio: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/path`. ![HTTP Listener configuration window and Path field set to /test](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-1.png) 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Listener** in the app. 5. Set **Host** to `0.0.0.0` and **Port** to `8081`. ![HTTP Listener global configuration window with Host field set to 0.0.0.0 and Port field to 8081](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-2.png) 6. Click the **TLS** tab. 7. Set **TLS configuration** to **Edit inline**. 8. In the **Trust Store Configuration** section, set **Path** to `keystore.jks` and **Password** to `MyP455W0rD`. ![Trust Store Configuration window with Path field set to keystore.jks and Password field to MyP455W0rD](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-3.png) 9. Click **OK**. In the **Configuration XML** editor, the `host`, `port`, `path` and `trust-store` configurations look like these: ```xml ``` To configure the **Base path** field for the source: 1. In the HTTP **Listener** configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to configure a global element. 2. In **HTTP Listener config**, set **Base path** to `api/v1`. ![HTTP Listener global configuration window with Base path field set to api/v1](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-4.png) 3. Click **OK**. In the **Configuration XML** editor, the `basePath` configuration looks like this: ```xml ``` > [!NOTE] If you deploy a project to CloudHub, set **Host** to **0.0.0.0** so the connection listens > to all the interfaces of the machine. > If you deploy locally for testing purposes, set **Host** to **localhost** to receive only requests > that are generated locally. The app is not vulnerable to external threats. You can also configure advanced settings that can define whether the connections are persistent and, if they are not, the timeout the connections will have. ## Configure Paths Because an HTTP **Listener** source acts as an event trigger within flows, it must reference the configuration to use and the path where the source listens for HTTP requests. Paths can be either static, which requires exact matches, or feature placeholders. Placeholders can be: - Wildcards (`*`) Match anything they are compared to. Wildcards at the end of a path can help provide better error messages by capturing requests to unmanaged resources. - Parameters (`{param}`) Match not only anything they are compared to but also capture those values on a URI parameters map. The following examples show different path configurations for three HTTP **Listener** sources, the paths are defined in the **Path** field and the **Base path** field is set to `api/v1`: - `account/mulesoft/main-contact` Matches only the exact path request `http://awesome-company.com/api/v1/account/mulesoft/main-contact`. - `account/{accountId}/main-contact` Matches all path requests structured similarly, such as `http://awesome-company.com/api/v1/account/salesforce/main-contact`, and saves `salesforce` as the value of `accountId`. - `account/{accountId}/*` Matches all path requests different from `main-contact`, such as `http://awesome-company.com/api/v1/account/mulesoft/users`, and saves `mulesoft` as the value of `accountId`. When the Mule app has multiple HTTP **Listener** sources, HTTP requests are always routed to the most specific source. In the previous examples, the first HTTP **Listener** source receives a request with `accountId: mulesoft` and suffix `main-contact`, and the second source receives any different `accountId` value. ## Configure Allowed Methods HTTP requests are routed based on the HTTP method received. By default, an HTTP **Listener** source supports all methods, but you can restrict the available methods or even configure custom ones. The following example shows how to configure the **Allowed methods** field in Studio: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. In the HTTP **Listener** source configuration screen, click the **Advanced** tab. 4. Set **Allowed methods** to `GET`. ![HTTP Listener configuration window and Allowed methods field set to GET](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-5.png) In the **Configuration XML** editor, the `allowedMethods` configuration looks like this: ```xml ``` When a Mule app has multiple HTTP **Listener** sources, requests are routed to the first source matching the method, so default sources should always be defined last. The following example shows different HTTP **Listener** source configurations, in which the **Allowed method** field is set to `GET`, `POST` and `PUT`. These different configurations cause HTTP requests to be routed to different flows, enabling you to specify and restrict user access to your data: ```xml ``` ## Configure Response Streaming Mode When HTTP Connector manages response bodies, the connector considers the type of data to send and uses _chunked_ encoding when the body size is not clear. This causes streams with no size information. To control this behavior, configure the **Response streaming mode** field to any of these options: - **AUTO (default)** Uses `Content-Length` encoding if a size is defined for the body, otherwise uses `Transfer-Encoding: chunked`. - **ALWAYS** Uses `Transfer-Encoding: chunked` regardless of any size data present. - **NEVER** Uses `Content-Length` encoding, consuming streams if necessary to determine the data size. The following example shows how to configure the **Response streaming mode** field in Studio. In the example, the main contact data for an account always returns `Content-Length` encoding: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `account/{accountId}/main-contact`. 4. In the HTTP **Listener** source configuration screen, click the **Advanced** tab. 5. Set **Allowed methods** to `GET`. 6. Set **Response streaming mode** to `NEVER`. ![HTTP Listener configuration window with Allowed methods field set to GET and Response streaming mode field set to NEVER](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-6.png) In the **Configuration XML** editor, the `allowedMethods` and `responseStreamingMode` configurations look like this: ```xml ``` ## Configure Read Timeout The read timeout means that if the HTTP **Listener** source doesn’t read data after read timeout milliseconds, the connector raises a timeout error. Use the **Read timeout** field to prevent a client from sending an HTTP request such as: ```JSON POST /test HTTP/1.1 Host: localhost:8081 Content-Length: 10000 2 ``` Notice that you don’t specify a read timeout, the **Listener** source waits for data for ever, and the connection is not released. The **Read timeout** field defaults to a value of 30000, and the time unit in milliseconds. To configure the read timeout for the source, in the HTTP **Listener** configuration window, set the **Read timeout** field to the desired value: ![HTTP Listener configuration window with Read timeout field set to 30000](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-7.png) In the **Configuration XML** editor, the `readTimeout` configuration looks like this: ```xml ``` ## Configure Reject Invalid Transfer Encoding Headers Based on [RFC7230](https://www.rfc-editor.org/rfc/rfc7230.html) and [RFC2616](https://www.rfc-editor.org/rfc/rfc2616.html) valid Transfer-Encoding headers are `chunked`, `deflate`, `compress`, `identity`, and `gzip`. These headers are not case-sensitive. To reject requests with invalid Transfer-Encoding headers, in the HTTP **Listener** configuration window, select the **Reject invalid transfer encoding** checkbox: ![HTTP Listener configuration window with Reject invalid transfer encoding field selected](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-8.png) In the **Configuration XML** editor, the `rejectInvalidTransferEncoding` configuration looks like this: ```xml ``` ## Receiving HTTP Requests When an HTTP **Listener** source receives an HTTP request, the data from the HTTP request line includes the method, request path, query, URI parameters, and headers as attributes. The body sets the payload, and the `Content-Type` header sets the MIME type, which enables other components to inspect the payload MIME type. For example, DataWeave works with an HTTP payload without requiring any input information. You can refer to attributes, such as headers, query parameters, and so on using the `HttpRequestAttributes` syntax. When you configure an HTTP request, do not set the `Content-Type` header. Mule runtime engine automatically infers the header from the message payload. If you set the `Content-Type` header for payload formatted as `multipart/form-data`, the HTTP request fails with a 400 error status. Additionally, if an HTTP request contains any of these headers: `X-Correlation-ID` or `MULE_CORRELATION_ID`, these set the message’s correlation ID for traceability. ### HTTP Request Example The following example shows an HTTP request: ```JSON POST api/v1/account/salesforce/main-contact?overwrite=true¬ify=jane.doe¬ify=admin HTTP/1.1 Host: localhost:8081 Content-Type: application/json Content-Length: 166 X-Correlation-ID: 9cf32672-4f0b-4e8b-b988-40c13aae85b4 { "name": "John", "surname": "Doe", "role": "Senior Vice President", "organization": "Marketing", "phone": 701222369, "email": "john.doe@salesforce.com" } ``` The message’s correlation ID is `9cf32672-4f0b-4e8b-b988-40c13aae85b4`. The payload is in JSON format: ```JSON { "name": "John", "surname": "Doe", "role": "Senior Vice President", "organization": "Marketing", "phone": 701222369, "email": "john.doe@salesforce.com" } ``` The attributes include: - method: `POST` - listenerPath: `api/v1/account/{accountId}/main-contact` - requestPath: `api/v1/account/salesforce/main-contact` - relativePath: `account/salesforce/main-contact` - queryParams: a multimap with entries `overwrite=true`, `notify=jane.doe`, and `notify=admin` - uriParams: a map with entry `accountId ⇒ salesforce` - headers: a multimap with entries `Host=localhost:8081`, `Content-Type=application/json`, `Content-Length=166`, and `X-Correlation-ID=9cf32672-4f0b-4e8b-b988-40c13aae85b4` A DataWeave expression such as `#[payload.name ' ' payload.surname]` returns `John Doe` because DataWeave correctly interprets the JSON data. A DataWeave expression such as `#['Received a ' attributes.method ' request for account ' attributes.uriParams.accountId '. The following users are notified: ' ++ (attributes.queryParams.*notify joinBy ', ')]` returns `Received a POST request for account salesforce. The following users are notified: admin, jane.doe`. To access HTTP Listener attributes, use DataWeave syntax as shown in the following table:
HTTP objectMule runtime engine 4.x

Method

#[attributes.method]

Path

#[attributes.listenerPath]

Relative Path

#[attributes.relativePath]

Request URI

#[attributes.requestUri]

Query String

#[attributes.queryString]

Query Parameters

#[attributes.queryParams]

URI Parameters

#[attributes.uriParams]

Version

#[attributes.version]

Scheme

#[attributes.scheme]

Headers

#[attributes.headers]

Remote Address

#[attributes.remoteAddress]

Client Certificate

#[attributes.clientCertificate]

> [!NOTE] _Multimaps_ are similar to maps except they allow several values for a given key. > Multimaps return the first value when using a single-value selector (`.`), but they allow to > retrieve all values when using the multiple-value selector (`.*`). ### HTTP Request Mapping to Mule Event Example The following diagram shows an example of an HTTP request and its mapping to a Mule event. ![Map of HTTP Request to Mule Event](/mulesoft/current/en-us/http-connector/latest/_images/request-mule-msg-map.png) Use [DataWeave](https://docs.mulesoft.com/dataweave/latest/) language to access the HTTP request data attributes and payload. ### HTTP Request Multipart Form-Data Example The following example shows an HTTP request of an HTML form received by an HTTP **Listener** source. Additionally, the example shows how to use DataWeave expressions to read `multipart/form-data` content. Based on the following HTML form: ```xml
How would you like to identify the logo?
Which is the logo file?
What is the main color in the logo?
``` The HTTP **Listener** source receives the following `multipart/form-data` HTTP request: ```text POST /api/v1/account/mulesoft/logo HTTP/1.1 Content-Type: multipart/form-data; boundary=489691234097965980223899 Host: localhost:8081 content-length: 34332 --489691234097965980223899 Content-Disposition: form-data; name="name" Corporate Logo --489691234097965980223899 Content-Disposition: form-data; name="logo"; filename="MuleSoft_logo.png" Content-Type: image/png .PNG . ... IHDR.......L......~..... pHYs...#...#.x.?v.. .IDATx....q.W.6.....~".N....t....t..#.....LD0T.CF0b..:.3......Q..@...q]U*y\c.... ....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`% .$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....V"H....`%.$....^6.......|..P.....IEND.B`. --489691234097965980223899 Content-Disposition: form-data; name="color" blue --489691234097965980223899-- ``` You can use DataWeave expressions to access and read each HTTP request parameter data through the `parts` object, either by name or item number. For example, to access the second part of the HTTP request that contains the `Corporate Logo` parameters data, you can use `payload.parts.logo` or `payload.parts[1]`. The latter is useful when a name is not provided. Within each part, you can access its content and headers. For example, `payload.parts.color.content` returns `blue`, while `payload.parts.logo.headers.'Content-Type'` returns `application/png`. You can also access the filename of a part. For example, the `Content-Disposition` header is parsed to allow an expression like `payload.parts.logo.headers.'Content-Disposition'.filename`, which in this case returns `MuleSoft_logo.png`. Refer to the [Formats Supported by DataWeave](https://docs.mulesoft.com/dataweave/latest/dataweave-formats) documentation to learn about reading and writing multipart content. ## Sending HTTP Responses After the triggered flow finishes its execution, the HTTP **Listener** source sends either of the following default results: - Successful execution: an HTTP response with 200 status code and the message payload as the body - Unsuccessful execution: an HTTP error response with 500 status code with the flow error’s description as the body In the HTTP **Listener** source configuration, you can customize HTTP responses by providing the following parameters: - **Body** - **Headers** - **Status code** - **Reason phrase** Note that you can use DataWeave to generate content for each parameter, and variables to propagate data from the flow. ### Create Sending HTTP Responses Mule App Example The following example shows how to configure HTTP responses for the HTTP **Listener** source in Studio. The example is a Mule app flow where an endpoint stores logos for an account: - When storage is successful, an HTTP regular response returns the status code `201`, the reason phrase `Created`, and the body `Corporate Logo has been stored as a MuleSoft logo`. - When storage fails, an HTTP error response returns a status code defined through the `errorCode` variable (if available) or `500` by default. - The custom header returns `X-Time`. - The body returns `Corporate Logo could not be stored`. - If there is a `CONNECTIVITY` error storing the logo, the returned status code is `504`, while any other errors result in a `500` status code. While a reason phrase is not defined for error responses, HTTP Connector attempts to define a reason phrase based on the status code. Thereby, a `Gateway Timeout` or `Internal Server Error` error can be returned for the previous explained HTTP responses scenarios. To test the Mule app you need a table named `logo` with two columns: `(accountId,logoName)`. You can use Mule to create the table or create it some other way. For example, the following XML code shows how to create the table using the Database Connector **Execute script** operation: ```xml ``` To create the Mule app in Studio, follow these steps: 1. In the **Mule Palette** view, select **HTTP>Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/account/{accountId}/logo`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Listener** in the app. 5. Set **Host** to `0.0.0.0` and **Port** to `8081`. 6. Click **OK**. 7. In the HTTP **Listener** configuration screen, click the **Responses** tab. 8. In the **Response** section, set these values: - **Body** : `output text/plain --- vars.logoName ' has been stored as a ' vars.accountId ++ ' logo.'` - **Status code** : `201` - **Reason phrase** : `Created` 9. In the **Error Response** section, set these values: - **Body** : `vars.logoName ++ ' could not be stored.'` - **Headers** : ```DataWeave output application/java --- { "X-Time" : "50s" // 4 } ``` - **Status code** : `vars.errorCode default 500`. ![HTTP Listener Responses configuration window with Body](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-9.png) 10. Drag a **Set Variable** component to the right of HTTP **Listener**. 11. Set **Name** to `logoName`. 12. Set **Value** to the expression `payload.parts.name.content`. 13. Drag another **Set Variable** component to the right of first **Set Variable** component. 14. Set **Name** to `accountId`. 15. Set **Value** to the expression `attributes.uriParams.accountId`. 16. Drag a Database **Insert** operation to the right of the second **Set Variable** component. 17. Click the plus sign (**+**) next to the **Connector configuration** field to configure the database connection. For further information about how to configure a database connection, refer to the [configure a database connection](https://docs.mulesoft.com/db-connector/latest/database-connector-connection) documentation. 18. In the **Insert** operation configuration screen, set **SQL Query Text** to `INSERT INTO logo (accountId,logoName) VALUES (:accountId, :logoName`). 19. Set **Input parameters** to the expression `{'accountId': vars.accountId as String, 'logoName': vars.logoName as String}`. 20. Drag an **On Error Propagate** component in the **Error handling** section of the flow. 21. Set **Type** to `DB:CONNECTIVITY`. 22. Drag a **Set Variable** component into the **On Error Propagate** component. 23. Set **Name** to `errorCode`. 24. Set **Value** to `504`. 25. Save and run your Mule app. 26. Send the following CURL command: `curl -v -F 'data=@/path/to/MuleSoft_logo.svg' -F name=mulesoftlogo [http://localhost:8081/account/muley/logo](http://localhost:8081/account/muley/logo)`. Note that the complete payload has been hidden because the content length is too big to be human readable: ```json * Trying 127.0.0.1... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 8081 (#0) > POST /account/muley/logo HTTP/1.1 > Host: localhost:8081 > User-Agent: curl/7.64.1 > Accept: */* > Content-Length: 5313 > Content-Type: multipart/form-data; boundary=------------------------d96e85d23101a1c3 > Expect: 100-continue > < HTTP/1.1 100 Continue * We are completely uploaded and fine < HTTP/1.1 201 Created < Content-Type: text/plain; charset=UTF-8 < Content-Length: 45 < Date: Tue, 18 Jan 2022 20:30:20 GMT < * Connection #0 to host localhost left intact mulesoftlogo has been stored as a muley logo.* Closing connection 0 ``` ### XML for Sending HTTP Responses Mule App Example Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation) - [HTTP Connector Troubleshooting Guide](https://docs.mulesoft.com/http-connector/latest/http-troubleshooting) - [DataWeave Formats](https://docs.mulesoft.com/dataweave/latest/dataweave-formats) - [TLS Configuration](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) - [HTTP Request Attributes Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation#HttpRequestAttributes) - [HTTP Response Attributes Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation#HttpResponseAttributes) # Configure HTTP Request Authentication The Anypoint Connector for HTTP (HTTP Connector) **Request** operation supports connecting a Mule client app to a service that requires any of the following types of authentication: - [Basic Authentication](#basic-authentication) - [Digest Authentication](#digest-authentication) - [NTLM Authentication](#ntlm-authentication) - [OAuth2 Authorization Code Grant Type Authentication](#oauth2-grant-authentication) - [OAuth2 Client Credentials Grant Type Authentication](#oauth2-client-authentication) If the target HTTP service of your request requires that you authenticate, provide the necessary credentials in the HTTP **Request** operation global configuration element. Mule runtime engine (Mule) uses the credentials you configured in the authorization header of the HTTP request. You can also configure Transport Layer Security (TLS) to encrypt the OAuth credentials. To protect your API or Mule app from receiving requests from an unauthorized source, use an API Manager policy. Refer to the [OAuth 2.0 Access Token Enforcement Using External Provider](https://docs.mulesoft.com/mule-gateway/policies-included-oauth-access-token-enforcement) documentation.
In Anypoint Studio HTTP Request operation global configuration, do not use the Expression option for the Authentication field.
## [](#http-xml-auth-setup)HTTP XML Authentication Setup XML values for HTTP Connector authentication:
Authentication Type XML Value

Basic Authentication

<http:authentication >
  <http:basic-authentication
  username="UN" password="PW"/>
</http:authentication>

NTLM Authentication

<http:authentication >
  <http:ntlm-authentication
  domain="DM" workstation="WS"
  username="UN" password="PW" />
</http:authentication>

Digest Authentication

<http:authentication >
  <http:digest-authentication
  username="UN" password="PW"/>
</http:authentication>
In addition, adding an OAuth component’s operation to the canvas in Studio automatically adds the following dependency to the project’s `pom.xml` file: ```xml org.mule.modules mule-oauth-module 1.1.8 mule-plugin ``` ## [](#basic-authentication)Configure Basic Authentication The basic authentication method enables an HTTP user agent to provide a username and password when making an HTTP request. The following Mule app example illustrates how to configure basic authentication for the HTTP **Request** operation by sending a request to the [GitHub API](https://docs.github.com/en/rest) for user information. In this example, the GitHub API accepts requests for user information on port 443 to `https://api.github.com/user`. To comply with basic authentication requirements, the Mule app provides the GitHub user name and password. You configure the HTTP **Request** operation to provide these credentials. Note that this example requires that you have a GitHub account. 1. In Studio > **Mule Palette**, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/path`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the source in the app. 5. In the **HTTP Listener config** window, set the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Advanced** tab, set **Allowed methods** to `GET`. 8. Drag an HTTP **Request** operation next to the HTTP **Listener** source. 9. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the operation in the app. 10. In the **HTTP Request configuration** window, set the following fields: - **Name**: `HTTP_Request_configuration` - **Protocol**: `HTTPS` - **Host**: `api.github.com` - **Port**: `443` 11. Set **Authentication** to **Basic authentication**. 12. Set **Username** to your GitHub username account. 13. Set **Password** to either your GitHub password account or a [personal access token](https://github.com/settings/tokens). 14. Set **Preemptive** to **True (Default)**. 15. Click **OK**. ![HTTP Request basic authentication window configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-basic-authentication-1.png) 16. In the HTTP **Request** configuration window, set **Method** to **GET (Default)**. 17. Set **Path** to `/user`. 18. In the **Mule Palette**, select **Core > Transform message**. 19. Drag the **Transform message** component to the right of the HTTP **Request** operation. 20. In the **Output** properties window, change the output to the following DataWeave code: ```dataweave %dw 2.0 output application/json --- payload ``` 21. Save your Mule app. 22. Click **Run > Run as > Mule Application**. 23. To call the API, type `http://localhost:8081/` in your internet browser. The GitHub API returns your user information, for example: ```json { "login":"kahn", "id":16xxx343, "avatar_url":"https://avatars.githubusercontent.com/u/16xxx343?v=3"` ... } ``` If the browser returns `HTTP GET on resource 'https://api.github.com:443/user' failed: unauthorized (401)`, use a [personal access token](https://github.com/settings/tokens) instead of specifying your GitHub password. If you are generating a new token, you need only the **user** > **read:user** scope. ### [](#xml-for-configuring-basic-authentication-example)XML for Configuring Basic Authentication Example Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## [](#digest-authentication)Configure Digest Authentication The digest authentication method enables a web server to verify user credentials via the user’s web browser. The following example shows how to configure the digest authentication for the HTTP **Request** operation by sending a `GET` request to the URL `http://www.example.com/test`, adding an authorization header with the provided username and password. 1. In Studio, select the HTTP **Request** operation from your flow. 2. Set **Method** to `GET` and **Path** to `test`. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the operation in the app. 4. In the **HTTP Request configuration** window, set the following fields: - **Name**: `HTTP_Request_configuration` - **Protocol**: `HTTPS` - **Host**: `example.com` - **Port**: `8081` 5. Set **Authentication** to **Digest authentication**. 6. Set **Username** to `Username`. 7. Set **Password** to `Password`. 8. Click **OK**. ![HTTP Request digest authentication window configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-digest-authentication-1.png) ### [](#xml-for-configuring-digest-authentication-example)XML for Configuring Digest Authentication Example The following code shows how to configure the digest authentication in XML: ```xml ... ... ``` ## [](#ntlm-authentication)Configure NTLM Authentication NT LAN Manager (NTLM) authentication replaces the authentication protocol in Microsoft LAN Manager (LANMAN), an older Microsoft product. The following example shows how to configure the NTLM authentication for the HTTP **Request** operation by sending a `GET` request to the URL `http://www.example.com/test`, adding an authorization header with the provided username and password. 1. In Studio, select the HTTP **Request** operation from your flow. 2. Set **Method** to `GET` and **Path** to `test`. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the operation in the app. 4. In the **HTTP Request configuration** window, set the following fields: - **Name**: `HTTP_Request_configuration` - **Protocol**: `HTTPS` - **Host**: `example.com` - **Port**: `8081` 5. Set **Authentication** to **Ntlm authentication**. 6. Set **Username** to `Username`. 7. Set **Password** to `Password`. 8. Optionally, set **Domain** and **Workstation**. 9. Click **OK**. ![HTTP Request NTLM authentication window configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-NTLM-authentication-1.png) ### [](#xml-for-configuring-ntlm-authentication)XML for Configuring NTLM Authentication The following code shows how to configure the NTLM authentication in XML: ```xml ... ``` ## [](#oauth2-grant-authentication)Configure OAuth2 Authorization Code Grant Type Authentication The OAuth2 authorization code configures the OAuth 2.0 authorization code grant type. The OAuth authentication server holds the resources protected by OAuth. For example, API calls to the GitHub API can be authenticated through [GitHub server using OAuth](https://docs.github.com/en/rest/oauth/). Note that HTTP Connector supports only OAuth 2.0. The following example shows how to configure the OAuth2 Authorization code grant type authentication for the HTTP **Request** operation by creating a Mule app to access a protected resource, GitHub user data, on the GitHub OAuth authentication server. The example covers how to: - Set up authorization - Create a Mule app - Run the Mule app This example requires that you have a GitHub account. Before you create the Mule app, review the following diagrams that show the procedure of getting OAuth access token and returning token for data: ![Get OAuth access token diagram](/mulesoft/current/en-us/http-connector/1.10/_images/http-authentication-diagram-2.png) 1. Submit an HTTP request for GitHub access to the client app. 2. The client app redirects the request to the GitHub authentication server. 3. GitHub requests login credentials. 4. Log in an authorize the client app. 5. The GitHub authentication server returns an access token. 6. The client app listens for the next request. ![Return token for data diagram](/mulesoft/current/en-us/http-connector/1.10/_images/http-authentication-diagram-3.png) 1. Request the secured user data using the access token. 2. Redirect user data request. 3. The client app gets the user data from the GitHub authentication server. 4. The client app listens for the next request. ### [](#set-up-authorization)Set Up Authorization To set up the authorization, follow these steps: ![Set up authorization](/mulesoft/current/en-us/http-connector/1.10/_images/http-authentication-diagram-1.png) 1. Register the client application on the authentication server. The authentication server assigns a client ID and client secret to the Mule app. The app uses these credentials to identify itself to the authentication server. During the registration, provide the URL to the Mule app home page and the application callback URL. 2. Log in to GitHub. 3. [Register the application](https://github.com/settings/applications/new) in your GitHub personal settings. 4. On the **Register a new OAuth application** page, complete the following fields: - **Application name**: `oauth-grant-code` - **Homepage URL**: `http://localhost:8082` - **Authorization callback URL**: `http://localhost:8082/callback` 5. Click **Register application**. GitHub creates a page for the registered application on `https://github.com/settings/applications/` that includes the GitHub-assigned client ID and client secret. ### [](#create-the-mule-app)Create the Mule App Create a Mule app that uses the GitHub assigned client ID and client secret to access the user data on the GitHub OAuth2 authentication server. The Mule app consists of an HTTP **Listener** source, an HTTP **Request** operation, and a DataWeave **Transform message** component to transform plain text to JSON. In the HTTP **Request** operation, you configure access to the authentication server. To create the Mule app: 1. In Studio > **Mule Palette**, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the source in the app. 5. In the **HTTP Listener config** window, set the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Drag an **HTTP > Request** operation to the right of the **Listener** source. 7. Expand the **Package Explorer** window. 8. Expand your Mule app project. 9. Open the `pom.xml` file. 10. At the end of the `` section and before the `` statement, add the following statement to enable OAuth options for the **Request** operation: ```xml org.mule.modules mule-oauth-module 1.1.8 mule-plugin ``` 11. Select the HTTP **Request** operation from your flow, and in the properties editor for **Connector Configuration**, click the plus sign (**+**). 12. Set **Authentication** to **Authorization code grant type**. 13. Set the following required fields: - **External callback url**: `http://myapp.mycompany.com:8082/callback` The OAuth authentication server uses this URL to provide the authentication code to the Mule server so that the Mule server can retrieve the access token. This must be the externally visible address of the callback, not the local one. - **Local authorization url**: `https://localhost:8082/login` This URL enables you to authenticate and grant access to the app for your account. - **Authorization url**: `https://github.com/login/oauth/authorize` This URL redirects the user request from the Mule app to the authorization URL of the GitHub authentication server. - **Client id** The client ID that GitHub provided when you registered the app. - **Client secret** The client secret that GitHub provided when you registered the app. - **Token Manager** To access authorization information for client credentials and authorization codes, configure a token manager. If you don’t configure a token manager, the OAuth Module re-initializes every time a new request is made. - **Token url**: `https://github.com/login/oauth/access_token` The Mule client app sends the token to the token URL. Additionally, you can set these optional fields: - **Local callback url**: `http://localhost:8082/callback` This URL matches the value you configured for **External callback URL** when registering the app in GitHub. This is the configuration of the server that Mule creates to receive the requests that a remote host sends to the **External callback URL**. External and internal callback URLs are the same, one URL enables you to create a server in the runtime (internal) and the other URL enables the internet (external) to see the server. - **Response Access Token**: `#[payload.access_token]` This DataWeave expression extracts an access token. - **Response Refresh Token**: `[payload.access_token]` If the provider you use sends a refresh token, use a DataWeave expression for the refresh token as the following `[payload.refresh_token]`. In this example, however, GitHub doesn’t actually use a refresh token. ![Configure Authorization code grant type authentication](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauth-authentication-1.png) 14. Click **OK**. 15. Save your Mule app. ### [](#run-the-mule-client-app)Run the Mule Client App To run the Mule client app and get the GitHub user data, perform the following steps before the access token expires: 1. In the **Package Explorer** window, right-click the project name and choose **Run as > Mule Application**. The console shows the Mule app deploying. 2. In a browser, enter the local authorization URL `http://localhost:8082/login` to initiate the [OAuth2 dance](https://datatracker.ietf.org/doc/html/rfc6749). GitHub prompts you to log in. 3. Log in using your GitHub username and password. GitHub prompts you to authorize the application you registered to run. ![Github Authorize application page](/mulesoft/current/en-us/http-connector/1.10/_images/http-authentication-githubpage.png) 4. Click **Authorize application**. `Successfully retrieved access token` appears as body text in the browser you used to initiate the OAuth2 dance. 5. For the token to get data, enter the following URL in a browser: `http://localhost:8081/github` The GitHub API returns your user information: { "login":"kahn", "id":16xxx343,"avatar\_url":"https://avatars.githubusercontent.com/u/16xxx343?v=3"\` ... } ### [](#xml-for-configuring-oauth2-authorization-code-example)XML for Configuring OAuth2 Authorization Code Example The following code shows how to configure OAuth2 Authorization Code in XML: ```xml ``` ### [](#configure-oauth2-authorization-scopes)Configure OAuth2 Authorization Scopes Scopes in OAuth are like security roles. Configure scopes for the OAuth2 Authorization code grant type in the **Scopes** field by defining a comma-separated list of OAuth scopes available in the authentication server. 1. In Studio, select the HTTP **Request** operation from your flow. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element. 3. Set **Authentication** to **Authorization code grant type**. 4. Set **Scopes** to `access_user_details, read_user_files`. ![Configure Scopes field for OAuth Authentication](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauth-scopes.png) 5. Click **OK**. In the **Configuration XML** editor, the `scopes` configuration looks like this: ```xml ``` ### [](#configure-oauth2-authorization-custom-parameters)Configure OAuth2 Authorization Custom Parameters There are OAuth implementations that require or allow extra query parameters to be sent when calling the Authentication URL of the OAS. Configure these parameters for the OAuth2 authorization code grant type in the **Custom parameters** field: 1. In Studio, select the HTTP **Request** operation from your flow. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element. 3. Set **Authentication** to **Authorization code grant type**. 4. Set the following fields: - **External callback url**: `http://myapp.mycompany.com:8082/callback` - **Local authorization url**: `http://localhost:8082/login` - **Authorization url**: `https://github.com/login/oauth/authorize` - **Client id**: Client ID from your GitHub account - **Client secret**: Client secret from your GitHub account - **Token url**: `https://github.com/login/oauth/access_token` 5. Set **Custom parameters** to **Edit inline**. 6. Click the plus sign (**+**) to add a new custom parameter. 7. Set **Key** to `box_device_id` and **Value** to `123142`. 8. Repeat Step 6. 9. Set **Key** to `box_device_name` and **Value** to `my-phone`. ![Configure Custom Parameters field for OAuth Authentication](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauth-customparameter.png) 10. Click **OK**. In the **Configuration XML** editor, the `oauth:custom-parameter` configuration looks like this: ```xml ``` ### [](#configure-oauth2-authorization-redirect-uri)Configure OAuth2 Authorization Redirect URI The [OAuth 2.0 specification](https://datatracker.ietf.org/doc/html/rfc6749) describes checking the redirect URI from the destination site of the redirect. The OAuth authentication server uses the URL to provide the authentication code to the Mule server for retrieving the access token. If you provide this URL, Mule creates an endpoint at the URL for storing the authentication code unless there’s already an endpoint registered to manually extract the authorization code. To override the redirect URI (external `redirect_uri`), configure the external redirect URI in the **External callback url** field, which is useful for actions such as deploying applications to CloudHub. When you configure authentication, you can optionally configure the **Local callback url** field as well. For CloudHub, Mule has to create an endpoint with a format similar to the following: `https://.cloudhub.io/` To instruct Mule to create the endpoint for CloudHub in the correct format, include the **External callback url** field in your OAuth2 authorization code grant type configuration. ### [](#configure-oauth2-authorization-extract-parameters)Configure OAuth2 Authorization Extract Parameters After you obtain an authorization code from the authentication server, OAuth requests an access token from the token URL of the server. The format of the response to the token URL is not defined in the OAuth specification. Each implementation can return different response formats. By default, Mule expects the response to be in JSON format. When this is the case, HTTP requests know how to extract the required information, as long as the following fields are specified: - **Response access token** The JSON field is `access_token`. - **Response refresh token** The JSON field is `refresh_token`. - **Response expires in** The JSON field is `expires_in`. When the response is in JSON format, the parameters are automatically extracted and you can use [DataWeave expressions](https://docs.mulesoft.com/mule-runtime/latest/dataweave) to reference these values in the response to the token URL. When the response is not in JSON format, then you must first configure the connector so that it knows how to extract these values. In the following example, HTTP Connector expects the response to have a `Content-Type` of `application/x-www-form-urlencoded`, so the body of the response is transformed into a map in the payload. You extract the values from the map through DataWeave expressions, such as `#[payload.access_token]` (the default value for the **Response access token** and **Response refresh token**). 1. In Studio, select the HTTP **Request** operation from your flow and in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Authorization code grant type**. 3. Verify the default options for the following fields: - **Response access token**: `#[payload.access_token]` - **Response refresh token**: `#[payload.refresh_token]` - **Response expires in**: `#[payload.expires_in]` ![Configure Response access token](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauth-extractparameters.png) 1. Click **OK**. In the **Configuration XML** editor, the `responseAccessToken`, `responseRefreshToken` and `responseExpiresIn` configurations look like this: ```xml ``` ### [](#configure-oauth2-authorization-refresh-token-when)Configure OAuth2 Authorization Refresh Token When The access token you obtain from the token URL eventually expires. The length of time the token is valid depends on the authentication server implementation. After the access token expires, instead of going through the whole process once again, you can retrieve a new access token by using the refresh access token provided by the token URL response. Mule manages this behavior automatically. By default, when an HTTP request is executed, if the response has a status code of 401, Mule calls the token URL and gets a new access token. You can configure when Mule performs one of these requests to obtain a new access token using a [DataWeave expression](https://docs.mulesoft.com/mule-runtime/latest/dataweave). The expression is evaluated against the response of the HTTP Request call. 1. In Studio, select the HTTP **Request** operation from your flow and in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Authorization code grant type**. 3. Set **Request Token When** to **Expression**. 4. In the expression box, add the following DataWeave expression: `#[payload.response.status == 'unauthorized']` ![Configure Response Token When field for OAuth Authentication](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauth-refreshtoken.png) In the **Configuration XML** editor, the `refreshTokenWhen` configuration looks like this: ```xml ``` When a request authorization fails, the response contains an XML node named `status` with value `'unauthorized'`. In the previous example, the DataWeave expression evaluates that condition. When the condition evaluates to true, Mule sends a request to the token URL to retrieve a new access token. ### [](#configure-https-for-oauth-authorization)Configure HTTPS for OAuth Authorization When you need to use HTTPS for the communication with the authentication server, such as in a production environment, apply HTTPS encoding to the OAuth credentials in all requests, including those for the: - **Local authorization url** - **Authorization url** - **Redirect url** - **Token url** To configure HTTPS for OAuth Authorization code grant type: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **TLS Configuration** to **Global Reference**. ![TLS Configuration field set to Global reference](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauth-tls-1.png) 3. Click the green plus sign (**+**) next to the field to create a new TLS context. 4. For **Trust Store Configuration**, set the following fields: - **Path**: `your_trust_store` - **Password**: `your_password` 5. For **Key Store Configuration**, set the following fields: - **Path**: `your_keystore_path` - **Key Password**: `your_key_password` - **Password**: `your_password` ![TLS Context global configuration settings window](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauth-tls-2.png) 1. Click **OK**. In the **Configuration XML** editor, the `tls:context`, `tls:trust-store` and `tls:key-store` configurations look like this: ```xml ``` ## [](#oauth2-client-authentication)Configure OAuth2 Client Credentials Grant Type Authentication The OAuth authentication server (OAS) is a server that holds the resources that are protected by OAuth. For example, the Box server provides an API with OAuth authentication. Note that HTTP Connector supports only OAuth 2.0. The client application (CA) is the server that tries to access a protected resource that belongs to a resource owner (RO). For example, a Mule server tries to access the resources that belong to a Box user, and the resources are in a Box server. In this case, the RO is also the CA. This means that the CA is implicitly authorized by the RO, which makes the whole procedure a lot simpler. The following diagram illustrates the relationship between both CA and OAS: ![OAuth2 dance between CA and OAS](/mulesoft/current/en-us/http-connector/1.10/_images/http-authentication-diagram-4.png) To access protected resources: 1. The CA must register an app to the OAS server. When this occurs, the OAS assigns credentials to the CA that it can later use to identify itself: `client ID` and `client secret`. The OAS must also provide a `Token URL`, to which the CA can later send HTTP requests to retrieve an `access token` that is required when accessing the protected resources. 2. The CA makes a request to the `Token URL` of the OAS, containing its client ID to prove its identity. As a response, the OAS grants it an `access token`. 3. With the access token, the CA is now free to access the protected resources in the OAS as long as it includes the access token in the requests. Depending on the policies defined by the OAS, the token may eventually expire. Client credentials grant type is meant to be used by a client application to grant access to an application on behalf of itself, rather than on behalf of resource owner in the OAS. To get an access token, all you need is the application credentials. To configure the OAuth2 authorization code grant type for the HTTP **Request** operation, set the **Authentication** field to **Client credentials grant type**: 1. In Studio, select the HTTP Request Configuration global element where you want to use the OAuth client credentials grant type. 2. Set **Authentication** to **Client credentials grant type**. 3. Set the following fields: - **Client id** The client ID that GitHub provided when you registered the app. - **Client secret** The client secret that GitHub provided when you registered the app. - **Scopes** Scopes in OAuth are like security roles. - **Token URL** The Mule client app sends the token to the token URL. ![Client credentials grant type configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauthcc-authentication-1.png) 1. Click **OK**. When the Mule app is deployed, it tries to retrieve an access token. If the Mule app is not able to retrieve an access token, deployment fails. ### [](#xml-for-configuring-client-credentials-grant-type-authentication)XML for Configuring Client Credentials Grant Type Authentication The following code shows how to configure client credentials grant type authentication in XML: ```xml ``` ### [](#configure-oauth2-client-credential-extract-parameters)Configure OAuth2 Client Credential Extract Parameters The same behavior of extracting parameters from the token URL that applies to OAuth2 authorization code grant type applies to the client credentials grant type as well: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Client credentials grant type**. 3. Verify the default options for the following fields: - **Response access token**: `#[payload.access_token]` - **Response refresh token**: `#[payload.refresh_token]` - **Response expires in**: `#[payload.expires_in]` ![Configure Response access token](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauthcc-extractparameters.png) 1. Click **OK**. In the **Configuration XML** editor, the `responseAccessToken`, `responseRefreshToken` and `responseExpiresIn` configurations look like this: ```xml ``` ### [](#configure-oauth2-client-credential-refresh-access-token-when)Configure OAuth2 Client Credential Refresh Access Token When The same behavior of extracting parameters from the token URL that applies to OAuth2 authorization code grant type applies to the client credentials grant type as well: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Client credentials grant type**. 3. Set **Request Token When** to **Expression**. 4. In the expression box, add the following DataWeave expression: `#[payload.response.status == 'unauthorized']` ![Configure Response Token When field for OAuth2 Client credentials grant type](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauthcc-refreshtoken.png) 1. Click **OK**. In the **Configuration XML** editor, the `refreshTokenWhen` configuration looks like this: ```xml ``` ## [](#configure-a-token-manager)Configure a Token Manager To access authorization information for client credentials and authorization codes, configure a token manager: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Authorization code grant type**. 3. Set **Token manager** to **Edit inline**. 4. Click the plus sign (**+**) to create a new configuration that references an object store. ![Configure Token manager](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauth-tokenmanager-1.png) 1. Click **OK**. In the **Configuration XML** editor, the `tokenManager-ref` attribute references a `token-manager-config` element like this: ```xml ``` ### [](#token-manager-access-authorization)Token Manager - Access Authorization After you have a token manager associated with an authorization grant type,you can use OAuth module operations anywhere in your Mule app flows to access information from an OAuth authorization. If you use client credentials or an authorization code with a single resource owner, use the following OAuth module operations in a flow. These operations provide access to the OAuth authorization information from a token manager: ```xml ``` If you use an authorization code with multiple resource owners, use the following OAuth module operations: ```xml ``` #### [](#token-manager-examples)Token Manager Examples The following table includes examples of how to retrieve information from a token manager. Place these OAuth module operations in your flow after the HTTP **Request** operation that manages your OAuth authentication:
Function Result

<oauth:retrieve-access-token tokenManager="tokenManagerConfig" target="accessToken"/>

accessToken value accessible through vars.accessToken from DataWeave.

<oauth:retrieve-access-token tokenManager="tokenManagerConfig" resourceOwnerId="Peter" target="accessToken"/>

accessToken value for the resource owner identified with the ID Peter accessible through vars.accessToken from DataWeave.

<oauth:retrieve-refresh-token tokenManager="tokenManagerConfig" target="refreshToken"/>

refreshToken value accessible through vars.refreshToken from DataWeave.

<oauth:retrieve-expires-in tokenManager="tokenManagerConfig" target="expiresIn"/>

Expires in value accessible through vars.expiresIn from DataWeave.

<oauth:retrieve-state tokenManager="tokenManagerConfig" target="state"/>

State used for the authorization URL accessible through vars.state from DataWeave.

<oauth:retrieve-custom-token-response-param tokenManager="tokenManagerConfig" key="a_custom_param_name" target="customParam"/>

Custom parameter extracted from the token URL response accessible through vars.customParam from DataWeave.

<oauth:retrieve-custom-token-response-param tokenManager="tokenManagerConfig" resourceOwnerId="Peter" key="a_custom_param_name" target="customParam"/>

Custom parameter extracted from the token URL response for resource owner Peter accessible through vars.customParam from DataWeave.

### [](#configure-token-manager-access-token-invalidation)Configure Token Manager Access Token Invalidation When using a token manager, you can block a particular resource owner: 1. In Studio, drag the OAuth module **Invalidate oauth context** operation to your flow. 2. In the properties editor, set the token manager to point to the same token manager that your HTTP **Request** operation references when managing OAuth authentication. 3. Set **Resource owner id** to an expression that points to the resource owner you want to clear, for example, `#[vars.resourceOwnerId]`. ![Configure Token manager](/mulesoft/current/en-us/http-connector/1.10/_images/http-oauth-tokenmanager-2.png) In the **Configuration XML** editor, the `invalidate-oauth-context` configuration looks like this: ```xml ``` The **Invalidate oauth context** operation removes all of the OAuth information stored in the token manager. When using multiple resource owners with a single token manager, if you want to clear only the OAuth information of one resource owner, then specify the resource owner ID in the Invalidate OAuth Context element. ```xml ``` ### [](#configure-token-manager-object-store)Configure Token Manager Object Store By default, the token manager uses an in-memory object store to store credentials. You can configure the token manager object store by using the **Object store** field. For further information about object stores, refer to the documentation about [configuring a custom object store](https://docs.mulesoft.com/object-store-connector/latest/object-store-to-define-a-new-os). ## [](#access-resources-on-behalf-of-several-users)Access Resources on Behalf of Several Users When you need to access resources on behalf of several users, use SDK Connectors instead of using HTTP Connector in conjunction with the OAuth module. ## [](#see-also)See Also - [HTTP Connector Overview](https://docs.mulesoft.com/http-connector/1.10/) - [HTTP Connector XML Reference](https://docs.mulesoft.com/http-connector/1.10/http-connector-xml-reference) - [Object Store V2](https://docs.mulesoft.com/object-store/) # Configure HTTP Request Authentication The Anypoint Connector for HTTP (HTTP Connector) **Request** operation supports connecting a Mule client app to a service that requires any of the following types of authentication: - [Basic Authentication](#basic-authentication) - [Digest Authentication](#digest-authentication) - [NTLM Authentication](#ntlm-authentication) - [OAuth2 Authorization Code Grant Type Authentication](#oauth2-grant-authentication) - [OAuth2 Client Credentials Grant Type Authentication](#oauth2-client-authentication) If the target HTTP service of your request requires that you authenticate, provide the necessary credentials in the HTTP **Request** operation global configuration element. Mule runtime engine (Mule) uses the credentials you configured in the authorization header of the HTTP request. You can also configure Transport Layer Security (TLS) to encrypt the OAuth credentials. To protect your API or Mule app from receiving requests from an unauthorized source, use an API Manager policy. Refer to the [OAuth 2.0 Access Token Enforcement Using External Provider](https://docs.mulesoft.com/mule-gateway/policies-included-oauth-access-token-enforcement) documentation.
In Anypoint Studio HTTP Request operation global configuration, do not use the Expression option for the Authentication field.
## [](#http-xml-auth-setup)HTTP XML Authentication Setup XML values for HTTP Connector authentication:
Authentication Type XML Value

Basic Authentication

<http:authentication >
  <http:basic-authentication
  username="UN" password="PW"/>
</http:authentication>

NTLM Authentication

<http:authentication >
  <http:ntlm-authentication
  domain="DM" workstation="WS"
  username="UN" password="PW" />
</http:authentication>

Digest Authentication

<http:authentication >
  <http:digest-authentication
  username="UN" password="PW"/>
</http:authentication>
In addition, adding an OAuth component’s operation to the canvas in Studio automatically adds the following dependency to the project’s `pom.xml` file: ```xml org.mule.modules mule-oauth-module 1.1.8 mule-plugin ``` ## [](#basic-authentication)Configure Basic Authentication The basic authentication method enables an HTTP user agent to provide a username and password when making an HTTP request. The following Mule app example illustrates how to configure basic authentication for the HTTP **Request** operation by sending a request to the [GitHub API](https://docs.github.com/en/rest) for user information. In this example, the GitHub API accepts requests for user information on port 443 to `https://api.github.com/user`. To comply with basic authentication requirements, the Mule app provides the GitHub user name and password. You configure the HTTP **Request** operation to provide these credentials. Note that this example requires that you have a GitHub account. 1. In Studio > **Mule Palette**, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/path`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the source in the app. 5. In the **HTTP Listener config** window, set the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Advanced** tab, set **Allowed methods** to `GET`. 8. Drag an HTTP **Request** operation next to the HTTP **Listener** source. 9. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the operation in the app. 10. In the **HTTP Request configuration** window, set the following fields: - **Name**: `HTTP_Request_configuration` - **Protocol**: `HTTPS` - **Host**: `api.github.com` - **Port**: `443` 11. Set **Authentication** to **Basic authentication**. 12. Set **Username** to your GitHub username account. 13. Set **Password** to either your GitHub password account or a [personal access token](https://github.com/settings/tokens). 14. Set **Preemptive** to **True (Default)**. 15. Click **OK**. ![HTTP Request basic authentication window configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-basic-authentication-1.png) 16. In the HTTP **Request** configuration window, set **Method** to **GET (Default)**. 17. Set **Path** to `/user`. 18. In the **Mule Palette**, select **Core > Transform message**. 19. Drag the **Transform message** component to the right of the HTTP **Request** operation. 20. In the **Output** properties window, change the output to the following DataWeave code: ```dataweave %dw 2.0 output application/json --- payload ``` 21. Save your Mule app. 22. Click **Run > Run as > Mule Application**. 23. To call the API, type `http://localhost:8081/` in your internet browser. The GitHub API returns your user information, for example: ```json { "login":"kahn", "id":16xxx343, "avatar_url":"https://avatars.githubusercontent.com/u/16xxx343?v=3"` ... } ``` If the browser returns `HTTP GET on resource 'https://api.github.com:443/user' failed: unauthorized (401)`, use a [personal access token](https://github.com/settings/tokens) instead of specifying your GitHub password. If you are generating a new token, you need only the **user** > **read:user** scope. ### [](#xml-for-configuring-basic-authentication-example)XML for Configuring Basic Authentication Example Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## [](#digest-authentication)Configure Digest Authentication The digest authentication method enables a web server to verify user credentials via the user’s web browser. The following example shows how to configure the digest authentication for the HTTP **Request** operation by sending a `GET` request to the URL `http://www.example.com/test`, adding an authorization header with the provided username and password. 1. In Studio, select the HTTP **Request** operation from your flow. 2. Set **Method** to `GET` and **Path** to `test`. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the operation in the app. 4. In the **HTTP Request configuration** window, set the following fields: - **Name**: `HTTP_Request_configuration` - **Protocol**: `HTTPS` - **Host**: `example.com` - **Port**: `8081` 5. Set **Authentication** to **Digest authentication**. 6. Set **Username** to `Username`. 7. Set **Password** to `Password`. 8. Click **OK**. ![HTTP Request digest authentication window configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-digest-authentication-1.png) ### [](#xml-for-configuring-digest-authentication-example)XML for Configuring Digest Authentication Example The following code shows how to configure the digest authentication in XML: ```xml ... ... ``` ## [](#ntlm-authentication)Configure NTLM Authentication NT LAN Manager (NTLM) authentication replaces the authentication protocol in Microsoft LAN Manager (LANMAN), an older Microsoft product. The following example shows how to configure the NTLM authentication for the HTTP **Request** operation by sending a `GET` request to the URL `http://www.example.com/test`, adding an authorization header with the provided username and password. 1. In Studio, select the HTTP **Request** operation from your flow. 2. Set **Method** to `GET` and **Path** to `test`. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the operation in the app. 4. In the **HTTP Request configuration** window, set the following fields: - **Name**: `HTTP_Request_configuration` - **Protocol**: `HTTPS` - **Host**: `example.com` - **Port**: `8081` 5. Set **Authentication** to **Ntlm authentication**. 6. Set **Username** to `Username`. 7. Set **Password** to `Password`. 8. Optionally, set **Domain** and **Workstation**. 9. Click **OK**. ![HTTP Request NTLM authentication window configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-NTLM-authentication-1.png) ### [](#xml-for-configuring-ntlm-authentication)XML for Configuring NTLM Authentication The following code shows how to configure the NTLM authentication in XML: ```xml ... ``` ## [](#oauth2-grant-authentication)Configure OAuth2 Authorization Code Grant Type Authentication The OAuth2 authorization code configures the OAuth 2.0 authorization code grant type. The OAuth authentication server holds the resources protected by OAuth. For example, API calls to the GitHub API can be authenticated through [GitHub server using OAuth](https://docs.github.com/en/rest/oauth/). Note that HTTP Connector supports only OAuth 2.0. The following example shows how to configure the OAuth2 Authorization code grant type authentication for the HTTP **Request** operation by creating a Mule app to access a protected resource, GitHub user data, on the GitHub OAuth authentication server. The example covers how to: - Set up authorization - Create a Mule app - Run the Mule app This example requires that you have a GitHub account. Before you create the Mule app, review the following diagrams that show the procedure of getting OAuth access token and returning token for data: ![Get OAuth access token diagram](/mulesoft/current/en-us/http-connector/1.11/_images/http-authentication-diagram-2.png) 1. Submit an HTTP request for GitHub access to the client app. 2. The client app redirects the request to the GitHub authentication server. 3. GitHub requests login credentials. 4. Log in an authorize the client app. 5. The GitHub authentication server returns an access token. 6. The client app listens for the next request. ![Return token for data diagram](/mulesoft/current/en-us/http-connector/1.11/_images/http-authentication-diagram-3.png) 1. Request the secured user data using the access token. 2. Redirect user data request. 3. The client app gets the user data from the GitHub authentication server. 4. The client app listens for the next request. ### [](#set-up-authorization)Set Up Authorization To set up the authorization, follow these steps: ![Set up authorization](/mulesoft/current/en-us/http-connector/1.11/_images/http-authentication-diagram-1.png) 1. Register the client application on the authentication server. The authentication server assigns a client ID and client secret to the Mule app. The app uses these credentials to identify itself to the authentication server. During the registration, provide the URL to the Mule app home page and the application callback URL. 2. Log in to GitHub. 3. [Register the application](https://github.com/settings/applications/new) in your GitHub personal settings. 4. On the **Register a new OAuth application** page, complete the following fields: - **Application name**: `oauth-grant-code` - **Homepage URL**: `http://localhost:8082` - **Authorization callback URL**: `http://localhost:8082/callback` 5. Click **Register application**. GitHub creates a page for the registered application on `https://github.com/settings/applications/` that includes the GitHub-assigned client ID and client secret. ### [](#create-the-mule-app)Create the Mule App Create a Mule app that uses the GitHub assigned client ID and client secret to access the user data on the GitHub OAuth2 authentication server. The Mule app consists of an HTTP **Listener** source, an HTTP **Request** operation, and a DataWeave **Transform message** component to transform plain text to JSON. In the HTTP **Request** operation, you configure access to the authentication server. To create the Mule app: 1. In Studio > **Mule Palette**, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the source in the app. 5. In the **HTTP Listener config** window, set the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Drag an **HTTP > Request** operation to the right of the **Listener** source. 7. Expand the **Package Explorer** window. 8. Expand your Mule app project. 9. Open the `pom.xml` file. 10. At the end of the `` section and before the `` statement, add the following statement to enable OAuth options for the **Request** operation: ```xml org.mule.modules mule-oauth-module 1.1.8 mule-plugin ``` 11. Select the HTTP **Request** operation from your flow, and in the properties editor for **Connector Configuration**, click the plus sign (**+**). 12. Set **Authentication** to **Authorization code grant type**. 13. Set the following required fields: - **External callback url**: `http://myapp.mycompany.com:8082/callback` The OAuth authentication server uses this URL to provide the authentication code to the Mule server so that the Mule server can retrieve the access token. This must be the externally visible address of the callback, not the local one. - **Local authorization url**: `https://localhost:8082/login` This URL enables you to authenticate and grant access to the app for your account. - **Authorization url**: `https://github.com/login/oauth/authorize` This URL redirects the user request from the Mule app to the authorization URL of the GitHub authentication server. - **Client id** The client ID that GitHub provided when you registered the app. - **Client secret** The client secret that GitHub provided when you registered the app. - **Token Manager** To access authorization information for client credentials and authorization codes, configure a token manager. If you don’t configure a token manager, the OAuth Module re-initializes every time a new request is made. - **Token url**: `https://github.com/login/oauth/access_token` The Mule client app sends the token to the token URL. Additionally, you can set these optional fields: - **Local callback url**: `http://localhost:8082/callback` This URL matches the value you configured for **External callback URL** when registering the app in GitHub. This is the configuration of the server that Mule creates to receive the requests that a remote host sends to the **External callback URL**. External and internal callback URLs are the same, one URL enables you to create a server in the runtime (internal) and the other URL enables the internet (external) to see the server. - **Response Access Token**: `#[payload.access_token]` This DataWeave expression extracts an access token. - **Response Refresh Token**: `[payload.access_token]` If the provider you use sends a refresh token, use a DataWeave expression for the refresh token as the following `[payload.refresh_token]`. In this example, however, GitHub doesn’t actually use a refresh token. ![Configure Authorization code grant type authentication](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauth-authentication-1.png) 14. Click **OK**. 15. Save your Mule app. ### [](#run-the-mule-client-app)Run the Mule Client App To run the Mule client app and get the GitHub user data, perform the following steps before the access token expires: 1. In the **Package Explorer** window, right-click the project name and choose **Run as > Mule Application**. The console shows the Mule app deploying. 2. In a browser, enter the local authorization URL `http://localhost:8082/login` to initiate the [OAuth2 dance](https://datatracker.ietf.org/doc/html/rfc6749). GitHub prompts you to log in. 3. Log in using your GitHub username and password. GitHub prompts you to authorize the application you registered to run. ![Github Authorize application page](/mulesoft/current/en-us/http-connector/1.11/_images/http-authentication-githubpage.png) 4. Click **Authorize application**. `Successfully retrieved access token` appears as body text in the browser you used to initiate the OAuth2 dance. 5. For the token to get data, enter the following URL in a browser: `http://localhost:8081/github` The GitHub API returns your user information: { "login":"kahn", "id":16xxx343,"avatar\_url":"https://avatars.githubusercontent.com/u/16xxx343?v=3"\` ... } ### [](#xml-for-configuring-oauth2-authorization-code-example)XML for Configuring OAuth2 Authorization Code Example The following code shows how to configure OAuth2 Authorization Code in XML: ```xml ``` ### [](#configure-oauth2-authorization-scopes)Configure OAuth2 Authorization Scopes Scopes in OAuth are like security roles. Configure scopes for the OAuth2 Authorization code grant type in the **Scopes** field by defining a comma-separated list of OAuth scopes available in the authentication server. 1. In Studio, select the HTTP **Request** operation from your flow. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element. 3. Set **Authentication** to **Authorization code grant type**. 4. Set **Scopes** to `access_user_details, read_user_files`. ![Configure Scopes field for OAuth Authentication](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauth-scopes.png) 5. Click **OK**. In the **Configuration XML** editor, the `scopes` configuration looks like this: ```xml ``` ### [](#configure-oauth2-authorization-custom-parameters)Configure OAuth2 Authorization Custom Parameters There are OAuth implementations that require or allow extra query parameters to be sent when calling the Authentication URL of the OAS. Configure these parameters for the OAuth2 authorization code grant type in the **Custom parameters** field: 1. In Studio, select the HTTP **Request** operation from your flow. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element. 3. Set **Authentication** to **Authorization code grant type**. 4. Set the following fields: - **External callback url**: `http://myapp.mycompany.com:8082/callback` - **Local authorization url**: `http://localhost:8082/login` - **Authorization url**: `https://github.com/login/oauth/authorize` - **Client id**: Client ID from your GitHub account - **Client secret**: Client secret from your GitHub account - **Token url**: `https://github.com/login/oauth/access_token` 5. Set **Custom parameters** to **Edit inline**. 6. Click the plus sign (**+**) to add a new custom parameter. 7. Set **Key** to `box_device_id` and **Value** to `123142`. 8. Repeat Step 6. 9. Set **Key** to `box_device_name` and **Value** to `my-phone`. ![Configure Custom Parameters field for OAuth Authentication](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauth-customparameter.png) 10. Click **OK**. In the **Configuration XML** editor, the `oauth:custom-parameter` configuration looks like this: ```xml ``` ### [](#configure-oauth2-authorization-redirect-uri)Configure OAuth2 Authorization Redirect URI The [OAuth 2.0 specification](https://datatracker.ietf.org/doc/html/rfc6749) describes checking the redirect URI from the destination site of the redirect. The OAuth authentication server uses the URL to provide the authentication code to the Mule server for retrieving the access token. If you provide this URL, Mule creates an endpoint at the URL for storing the authentication code unless there’s already an endpoint registered to manually extract the authorization code. To override the redirect URI (external `redirect_uri`), configure the external redirect URI in the **External callback url** field, which is useful for actions such as deploying applications to CloudHub. When you configure authentication, you can optionally configure the **Local callback url** field as well. For CloudHub, Mule has to create an endpoint with a format similar to the following: `https://.cloudhub.io/` To instruct Mule to create the endpoint for CloudHub in the correct format, include the **External callback url** field in your OAuth2 authorization code grant type configuration. ### [](#configure-oauth2-authorization-extract-parameters)Configure OAuth2 Authorization Extract Parameters After you obtain an authorization code from the authentication server, OAuth requests an access token from the token URL of the server. The format of the response to the token URL is not defined in the OAuth specification. Each implementation can return different response formats. By default, Mule expects the response to be in JSON format. When this is the case, HTTP requests know how to extract the required information, as long as the following fields are specified: - **Response access token** The JSON field is `access_token`. - **Response refresh token** The JSON field is `refresh_token`. - **Response expires in** The JSON field is `expires_in`. When the response is in JSON format, the parameters are automatically extracted and you can use [DataWeave expressions](https://docs.mulesoft.com/mule-runtime/latest/dataweave) to reference these values in the response to the token URL. When the response is not in JSON format, then you must first configure the connector so that it knows how to extract these values. In the following example, HTTP Connector expects the response to have a `Content-Type` of `application/x-www-form-urlencoded`, so the body of the response is transformed into a map in the payload. You extract the values from the map through DataWeave expressions, such as `#[payload.access_token]` (the default value for the **Response access token** and **Response refresh token**). 1. In Studio, select the HTTP **Request** operation from your flow and in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Authorization code grant type**. 3. Verify the default options for the following fields: - **Response access token**: `#[payload.access_token]` - **Response refresh token**: `#[payload.refresh_token]` - **Response expires in**: `#[payload.expires_in]` ![Configure Response access token](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauth-extractparameters.png) 1. Click **OK**. In the **Configuration XML** editor, the `responseAccessToken`, `responseRefreshToken` and `responseExpiresIn` configurations look like this: ```xml ``` ### [](#configure-oauth2-authorization-refresh-token-when)Configure OAuth2 Authorization Refresh Token When The access token you obtain from the token URL eventually expires. The length of time the token is valid depends on the authentication server implementation. After the access token expires, instead of going through the whole process once again, you can retrieve a new access token by using the refresh access token provided by the token URL response. Mule manages this behavior automatically. By default, when an HTTP request is executed, if the response has a status code of 401, Mule calls the token URL and gets a new access token. You can configure when Mule performs one of these requests to obtain a new access token using a [DataWeave expression](https://docs.mulesoft.com/mule-runtime/latest/dataweave). The expression is evaluated against the response of the HTTP Request call. 1. In Studio, select the HTTP **Request** operation from your flow and in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Authorization code grant type**. 3. Set **Request Token When** to **Expression**. 4. In the expression box, add the following DataWeave expression: `#[payload.response.status == 'unauthorized']` ![Configure Response Token When field for OAuth Authentication](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauth-refreshtoken.png) In the **Configuration XML** editor, the `refreshTokenWhen` configuration looks like this: ```xml ``` When a request authorization fails, the response contains an XML node named `status` with value `'unauthorized'`. In the previous example, the DataWeave expression evaluates that condition. When the condition evaluates to true, Mule sends a request to the token URL to retrieve a new access token. ### [](#configure-https-for-oauth-authorization)Configure HTTPS for OAuth Authorization When you need to use HTTPS for the communication with the authentication server, such as in a production environment, apply HTTPS encoding to the OAuth credentials in all requests, including those for the: - **Local authorization url** - **Authorization url** - **Redirect url** - **Token url** To configure HTTPS for OAuth Authorization code grant type: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **TLS Configuration** to **Global Reference**. ![TLS Configuration field set to Global reference](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauth-tls-1.png) 3. Click the green plus sign (**+**) next to the field to create a new TLS context. 4. For **Trust Store Configuration**, set the following fields: - **Path**: `your_trust_store` - **Password**: `your_password` 5. For **Key Store Configuration**, set the following fields: - **Path**: `your_keystore_path` - **Key Password**: `your_key_password` - **Password**: `your_password` ![TLS Context global configuration settings window](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauth-tls-2.png) 1. Click **OK**. In the **Configuration XML** editor, the `tls:context`, `tls:trust-store` and `tls:key-store` configurations look like this: ```xml ``` ## [](#oauth2-client-authentication)Configure OAuth2 Client Credentials Grant Type Authentication The OAuth authentication server (OAS) is a server that holds the resources that are protected by OAuth. For example, the Box server provides an API with OAuth authentication. Note that HTTP Connector supports only OAuth 2.0. The client application (CA) is the server that tries to access a protected resource that belongs to a resource owner (RO). For example, a Mule server tries to access the resources that belong to a Box user, and the resources are in a Box server. In this case, the RO is also the CA. This means that the CA is implicitly authorized by the RO, which makes the whole procedure a lot simpler. The following diagram illustrates the relationship between both CA and OAS: ![OAuth2 dance between CA and OAS](/mulesoft/current/en-us/http-connector/1.11/_images/http-authentication-diagram-4.png) To access protected resources: 1. The CA must register an app to the OAS server. When this occurs, the OAS assigns credentials to the CA that it can later use to identify itself: `client ID` and `client secret`. The OAS must also provide a `Token URL`, to which the CA can later send HTTP requests to retrieve an `access token` that is required when accessing the protected resources. 2. The CA makes a request to the `Token URL` of the OAS, containing its client ID to prove its identity. As a response, the OAS grants it an `access token`. 3. With the access token, the CA is now free to access the protected resources in the OAS as long as it includes the access token in the requests. Depending on the policies defined by the OAS, the token may eventually expire. Client credentials grant type is meant to be used by a client application to grant access to an application on behalf of itself, rather than on behalf of resource owner in the OAS. To get an access token, all you need is the application credentials. To configure the OAuth2 authorization code grant type for the HTTP **Request** operation, set the **Authentication** field to **Client credentials grant type**: 1. In Studio, select the HTTP Request Configuration global element where you want to use the OAuth client credentials grant type. 2. Set **Authentication** to **Client credentials grant type**. 3. Set the following fields: - **Client id** The client ID that GitHub provided when you registered the app. - **Client secret** The client secret that GitHub provided when you registered the app. - **Scopes** Scopes in OAuth are like security roles. - **Token URL** The Mule client app sends the token to the token URL. ![Client credentials grant type configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauthcc-authentication-1.png)
Although the Client id and Client secret fields support using variables, the connector doesn’t support changing these values dynamically during each flow execution. The configured credentials must remain static. If you require multiple sets of client credentials, it is recommended to create a separate configuration for each client.
1. Click **OK**. When the Mule app is deployed, it tries to retrieve an access token. If the Mule app is not able to retrieve an access token, deployment fails. ### [](#xml-for-configuring-client-credentials-grant-type-authentication)XML for Configuring Client Credentials Grant Type Authentication The following code shows how to configure client credentials grant type authentication in XML: ```xml ``` ### [](#configure-oauth2-client-credential-extract-parameters)Configure OAuth2 Client Credential Extract Parameters The same behavior of extracting parameters from the token URL that applies to OAuth2 authorization code grant type applies to the client credentials grant type as well: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Client credentials grant type**. 3. Verify the default options for the following fields: - **Response access token**: `#[payload.access_token]` - **Response refresh token**: `#[payload.refresh_token]` - **Response expires in**: `#[payload.expires_in]` ![Configure Response access token](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauthcc-extractparameters.png) 1. Click **OK**. In the **Configuration XML** editor, the `responseAccessToken`, `responseRefreshToken` and `responseExpiresIn` configurations look like this: ```xml ``` ### [](#configure-oauth2-client-credential-refresh-access-token-when)Configure OAuth2 Client Credential Refresh Access Token When The same behavior of extracting parameters from the token URL that applies to OAuth2 authorization code grant type applies to the client credentials grant type as well: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Client credentials grant type**. 3. Set **Request Token When** to **Expression**. 4. In the expression box, add the following DataWeave expression: `#[payload.response.status == 'unauthorized']` ![Configure Response Token When field for OAuth2 Client credentials grant type](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauthcc-refreshtoken.png) 1. Click **OK**. In the **Configuration XML** editor, the `refreshTokenWhen` configuration looks like this: ```xml ``` ## [](#configure-a-token-manager)Configure a Token Manager To access authorization information for client credentials and authorization codes, configure a token manager: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Authorization code grant type**. 3. Set **Token manager** to **Edit inline**. 4. Click the plus sign (**+**) to create a new configuration that references an object store. ![Configure Token manager](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauth-tokenmanager-1.png) 1. Click **OK**. In the **Configuration XML** editor, the `tokenManager-ref` attribute references a `token-manager-config` element like this: ```xml ``` ### [](#token-manager-access-authorization)Token Manager - Access Authorization After you have a token manager associated with an authorization grant type,you can use OAuth module operations anywhere in your Mule app flows to access information from an OAuth authorization. If you use client credentials or an authorization code with a single resource owner, use the following OAuth module operations in a flow. These operations provide access to the OAuth authorization information from a token manager: ```xml ``` If you use an authorization code with multiple resource owners, use the following OAuth module operations: ```xml ``` #### [](#token-manager-examples)Token Manager Examples The following table includes examples of how to retrieve information from a token manager. Place these OAuth module operations in your flow after the HTTP **Request** operation that manages your OAuth authentication:
Function Result

<oauth:retrieve-access-token tokenManager="tokenManagerConfig" target="accessToken"/>

accessToken value accessible through vars.accessToken from DataWeave.

<oauth:retrieve-access-token tokenManager="tokenManagerConfig" resourceOwnerId="Peter" target="accessToken"/>

accessToken value for the resource owner identified with the ID Peter accessible through vars.accessToken from DataWeave.

<oauth:retrieve-refresh-token tokenManager="tokenManagerConfig" target="refreshToken"/>

refreshToken value accessible through vars.refreshToken from DataWeave.

<oauth:retrieve-expires-in tokenManager="tokenManagerConfig" target="expiresIn"/>

Expires in value accessible through vars.expiresIn from DataWeave.

<oauth:retrieve-state tokenManager="tokenManagerConfig" target="state"/>

State used for the authorization URL accessible through vars.state from DataWeave.

<oauth:retrieve-custom-token-response-param tokenManager="tokenManagerConfig" key="a_custom_param_name" target="customParam"/>

Custom parameter extracted from the token URL response accessible through vars.customParam from DataWeave.

<oauth:retrieve-custom-token-response-param tokenManager="tokenManagerConfig" resourceOwnerId="Peter" key="a_custom_param_name" target="customParam"/>

Custom parameter extracted from the token URL response for resource owner Peter accessible through vars.customParam from DataWeave.

### [](#configure-token-manager-access-token-invalidation)Configure Token Manager Access Token Invalidation When using a token manager, you can block a particular resource owner: 1. In Studio, drag the OAuth module **Invalidate oauth context** operation to your flow. 2. In the properties editor, set the token manager to point to the same token manager that your HTTP **Request** operation references when managing OAuth authentication. 3. Set **Resource owner id** to an expression that points to the resource owner you want to clear, for example, `#[vars.resourceOwnerId]`. ![Configure Token manager](/mulesoft/current/en-us/http-connector/1.11/_images/http-oauth-tokenmanager-2.png) In the **Configuration XML** editor, the `invalidate-oauth-context` configuration looks like this: ```xml ``` The **Invalidate oauth context** operation removes all of the OAuth information stored in the token manager. When using multiple resource owners with a single token manager, if you want to clear only the OAuth information of one resource owner, then specify the resource owner ID in the Invalidate OAuth Context element. ```xml ``` ### [](#configure-token-manager-object-store)Configure Token Manager Object Store By default, the token manager uses an in-memory object store to store credentials. You can configure the token manager object store by using the **Object store** field. For further information about object stores, refer to the documentation about [configuring a custom object store](https://docs.mulesoft.com/object-store-connector/latest/object-store-to-define-a-new-os). ## [](#access-resources-on-behalf-of-several-users)Access Resources on Behalf of Several Users When you need to access resources on behalf of several users, use SDK Connectors instead of using HTTP Connector in conjunction with the OAuth module. ## [](#see-also)See Also - [HTTP Connector Overview](https://docs.mulesoft.com/http-connector/1.11/) - [HTTP Connector XML Reference](https://docs.mulesoft.com/http-connector/1.11/http-connector-xml-reference) - [Object Store V2](https://docs.mulesoft.com/object-store/) # Configure HTTP Request Authentication The Anypoint Connector for HTTP (HTTP Connector) **Request** operation supports connecting a Mule client app to a service that requires any of the following types of authentication: - [Basic Authentication](#basic-authentication) - [Digest Authentication](#digest-authentication) - [NTLM Authentication](#ntlm-authentication) - [OAuth2 Authorization Code Grant Type Authentication](#oauth2-grant-authentication) - [OAuth2 Client Credentials Grant Type Authentication](#oauth2-client-authentication) If the target HTTP service of your request requires that you authenticate, provide the necessary credentials in the HTTP **Request** operation global configuration element. Mule runtime engine (Mule) uses the credentials you configured in the authorization header of the HTTP request. You can also configure Transport Layer Security (TLS) to encrypt the OAuth credentials. To protect your API or Mule app from receiving requests from an unauthorized source, use an API Manager policy. Refer to the [OAuth 2.0 Access Token Enforcement Using External Provider](https://docs.mulesoft.com/mule-gateway/policies-included-oauth-access-token-enforcement) documentation.
In Anypoint Studio HTTP Request operation global configuration, do not use the Expression option for the Authentication field.
## [](#http-xml-auth-setup)HTTP XML Authentication Setup XML values for HTTP Connector authentication:
Authentication Type XML Value

Basic Authentication

<http:authentication >
  <http:basic-authentication
  username="UN" password="PW"/>
</http:authentication>

NTLM Authentication

<http:authentication >
  <http:ntlm-authentication
  domain="DM" workstation="WS"
  username="UN" password="PW" />
</http:authentication>

Digest Authentication

<http:authentication >
  <http:digest-authentication
  username="UN" password="PW"/>
</http:authentication>
In addition, adding an OAuth component’s operation to the canvas in Studio automatically adds the following dependency to the project’s `pom.xml` file: ```xml org.mule.modules mule-oauth-module 1.1.8 mule-plugin ``` ## [](#basic-authentication)Configure Basic Authentication The basic authentication method enables an HTTP user agent to provide a username and password when making an HTTP request. The following Mule app example illustrates how to configure basic authentication for the HTTP **Request** operation by sending a request to the [GitHub API](https://docs.github.com/en/rest) for user information. In this example, the GitHub API accepts requests for user information on port 443 to `https://api.github.com/user`. To comply with basic authentication requirements, the Mule app provides the GitHub user name and password. You configure the HTTP **Request** operation to provide these credentials. Note that this example requires that you have a GitHub account. 1. In Studio > **Mule Palette**, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/path`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the source in the app. 5. In the **HTTP Listener config** window, set the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. 7. In the **Advanced** tab, set **Allowed methods** to `GET`. 8. Drag an HTTP **Request** operation next to the HTTP **Listener** source. 9. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the operation in the app. 10. In the **HTTP Request configuration** window, set the following fields: - **Name**: `HTTP_Request_configuration` - **Protocol**: `HTTPS` - **Host**: `api.github.com` - **Port**: `443` 11. Set **Authentication** to **Basic authentication**. 12. Set **Username** to your GitHub username account. 13. Set **Password** to either your GitHub password account or a [personal access token](https://github.com/settings/tokens). 14. Set **Preemptive** to **True (Default)**. 15. Click **OK**. ![HTTP Request basic authentication window configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-basic-authentication-1.png) 16. In the HTTP **Request** configuration window, set **Method** to **GET (Default)**. 17. Set **Path** to `/user`. 18. In the **Mule Palette**, select **Core > Transform message**. 19. Drag the **Transform message** component to the right of the HTTP **Request** operation. 20. In the **Output** properties window, change the output to the following DataWeave code: ```dataweave %dw 2.0 output application/json --- payload ``` 21. Save your Mule app. 22. Click **Run > Run as > Mule Application**. 23. To call the API, type `http://localhost:8081/` in your internet browser. The GitHub API returns your user information, for example: ```json { "login":"kahn", "id":16xxx343, "avatar_url":"https://avatars.githubusercontent.com/u/16xxx343?v=3"` ... } ``` If the browser returns `HTTP GET on resource 'https://api.github.com:443/user' failed: unauthorized (401)`, use a [personal access token](https://github.com/settings/tokens) instead of specifying your GitHub password. If you are generating a new token, you need only the **user** > **read:user** scope. ### [](#xml-for-configuring-basic-authentication-example)XML for Configuring Basic Authentication Example Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## [](#digest-authentication)Configure Digest Authentication The digest authentication method enables a web server to verify user credentials via the user’s web browser. The following example shows how to configure the digest authentication for the HTTP **Request** operation by sending a `GET` request to the URL `http://www.example.com/test`, adding an authorization header with the provided username and password. 1. In Studio, select the HTTP **Request** operation from your flow. 2. Set **Method** to `GET` and **Path** to `test`. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the operation in the app. 4. In the **HTTP Request configuration** window, set the following fields: - **Name**: `HTTP_Request_configuration` - **Protocol**: `HTTPS` - **Host**: `example.com` - **Port**: `8081` 5. Set **Authentication** to **Digest authentication**. 6. Set **Username** to `Username`. 7. Set **Password** to `Password`. 8. Click **OK**. ![HTTP Request digest authentication window configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-digest-authentication-1.png) ### [](#xml-for-configuring-digest-authentication-example)XML for Configuring Digest Authentication Example The following code shows how to configure the digest authentication in XML: ```xml ... ... ``` ## [](#ntlm-authentication)Configure NTLM Authentication NT LAN Manager (NTLM) authentication replaces the authentication protocol in Microsoft LAN Manager (LANMAN), an older Microsoft product. The following example shows how to configure the NTLM authentication for the HTTP **Request** operation by sending a `GET` request to the URL `http://www.example.com/test`, adding an authorization header with the provided username and password. 1. In Studio, select the HTTP **Request** operation from your flow. 2. Set **Method** to `GET` and **Path** to `test`. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the operation in the app. 4. In the **HTTP Request configuration** window, set the following fields: - **Name**: `HTTP_Request_configuration` - **Protocol**: `HTTPS` - **Host**: `example.com` - **Port**: `8081` 5. Set **Authentication** to **Ntlm authentication**. 6. Set **Username** to `Username`. 7. Set **Password** to `Password`. 8. Optionally, set **Domain** and **Workstation**. 9. Click **OK**. ![HTTP Request NTLM authentication window configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-NTLM-authentication-1.png) ### [](#xml-for-configuring-ntlm-authentication)XML for Configuring NTLM Authentication The following code shows how to configure the NTLM authentication in XML: ```xml ... ``` ## [](#oauth2-grant-authentication)Configure OAuth2 Authorization Code Grant Type Authentication The OAuth2 authorization code configures the OAuth 2.0 authorization code grant type. The OAuth authentication server holds the resources protected by OAuth. For example, API calls to the GitHub API can be authenticated through [GitHub server using OAuth](https://docs.github.com/en/rest/oauth/). Note that HTTP Connector supports only OAuth 2.0. The following example shows how to configure the OAuth2 Authorization code grant type authentication for the HTTP **Request** operation by creating a Mule app to access a protected resource, GitHub user data, on the GitHub OAuth authentication server. The example covers how to: - Set up authorization - Create a Mule app - Run the Mule app This example requires that you have a GitHub account. Before you create the Mule app, review the following diagrams that show the procedure of getting OAuth access token and returning token for data: ![Get OAuth access token diagram](/mulesoft/current/en-us/http-connector/latest/_images/http-authentication-diagram-2.png) 1. Submit an HTTP request for GitHub access to the client app. 2. The client app redirects the request to the GitHub authentication server. 3. GitHub requests login credentials. 4. Log in an authorize the client app. 5. The GitHub authentication server returns an access token. 6. The client app listens for the next request. ![Return token for data diagram](/mulesoft/current/en-us/http-connector/latest/_images/http-authentication-diagram-3.png) 1. Request the secured user data using the access token. 2. Redirect user data request. 3. The client app gets the user data from the GitHub authentication server. 4. The client app listens for the next request. ### [](#set-up-authorization)Set Up Authorization To set up the authorization, follow these steps: ![Set up authorization](/mulesoft/current/en-us/http-connector/latest/_images/http-authentication-diagram-1.png) 1. Register the client application on the authentication server. The authentication server assigns a client ID and client secret to the Mule app. The app uses these credentials to identify itself to the authentication server. During the registration, provide the URL to the Mule app home page and the application callback URL. 2. Log in to GitHub. 3. [Register the application](https://github.com/settings/applications/new) in your GitHub personal settings. 4. On the **Register a new OAuth application** page, complete the following fields: - **Application name**: `oauth-grant-code` - **Homepage URL**: `http://localhost:8082` - **Authorization callback URL**: `http://localhost:8082/callback` 5. Click **Register application**. GitHub creates a page for the registered application on `https://github.com/settings/applications/` that includes the GitHub-assigned client ID and client secret. ### [](#create-the-mule-app)Create the Mule App Create a Mule app that uses the GitHub assigned client ID and client secret to access the user data on the GitHub OAuth2 authentication server. The Mule app consists of an HTTP **Listener** source, an HTTP **Request** operation, and a DataWeave **Transform message** component to transform plain text to JSON. In the HTTP **Request** operation, you configure access to the authentication server. To create the Mule app: 1. In Studio > **Mule Palette**, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. Set **Path** to `/`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the source in the app. 5. In the **HTTP Listener config** window, set the following fields: - **Protocol**: `HTTP (Default)` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Drag an **HTTP > Request** operation to the right of the **Listener** source. 7. Expand the **Package Explorer** window. 8. Expand your Mule app project. 9. Open the `pom.xml` file. 10. At the end of the `` section and before the `` statement, add the following statement to enable OAuth options for the **Request** operation: ```xml org.mule.modules mule-oauth-module 1.1.8 mule-plugin ``` 11. Select the HTTP **Request** operation from your flow, and in the properties editor for **Connector Configuration**, click the plus sign (**+**). 12. Set **Authentication** to **Authorization code grant type**. 13. Set the following required fields: - **External callback url**: `http://myapp.mycompany.com:8082/callback` The OAuth authentication server uses this URL to provide the authentication code to the Mule server so that the Mule server can retrieve the access token. This must be the externally visible address of the callback, not the local one. - **Local authorization url**: `https://localhost:8082/login` This URL enables you to authenticate and grant access to the app for your account. - **Authorization url**: `https://github.com/login/oauth/authorize` This URL redirects the user request from the Mule app to the authorization URL of the GitHub authentication server. - **Client id** The client ID that GitHub provided when you registered the app. - **Client secret** The client secret that GitHub provided when you registered the app. - **Token Manager** To access authorization information for client credentials and authorization codes, configure a token manager. If you don’t configure a token manager, the OAuth Module re-initializes every time a new request is made. - **Token url**: `https://github.com/login/oauth/access_token` The Mule client app sends the token to the token URL. Additionally, you can set these optional fields: - **Local callback url**: `http://localhost:8082/callback` This URL matches the value you configured for **External callback URL** when registering the app in GitHub. This is the configuration of the server that Mule creates to receive the requests that a remote host sends to the **External callback URL**. External and internal callback URLs are the same, one URL enables you to create a server in the runtime (internal) and the other URL enables the internet (external) to see the server. - **Response Access Token**: `#[payload.access_token]` This DataWeave expression extracts an access token. - **Response Refresh Token**: `[payload.access_token]` If the provider you use sends a refresh token, use a DataWeave expression for the refresh token as the following `[payload.refresh_token]`. In this example, however, GitHub doesn’t actually use a refresh token. ![Configure Authorization code grant type authentication](/mulesoft/current/en-us/http-connector/latest/_images/http-oauth-authentication-1.png) 14. Click **OK**. 15. Save your Mule app. ### [](#run-the-mule-client-app)Run the Mule Client App To run the Mule client app and get the GitHub user data, perform the following steps before the access token expires: 1. In the **Package Explorer** window, right-click the project name and choose **Run as > Mule Application**. The console shows the Mule app deploying. 2. In a browser, enter the local authorization URL `http://localhost:8082/login` to initiate the [OAuth2 dance](https://datatracker.ietf.org/doc/html/rfc6749). GitHub prompts you to log in. 3. Log in using your GitHub username and password. GitHub prompts you to authorize the application you registered to run. ![Github Authorize application page](/mulesoft/current/en-us/http-connector/latest/_images/http-authentication-githubpage.png) 4. Click **Authorize application**. `Successfully retrieved access token` appears as body text in the browser you used to initiate the OAuth2 dance. 5. For the token to get data, enter the following URL in a browser: `http://localhost:8081/github` The GitHub API returns your user information: { "login":"kahn", "id":16xxx343,"avatar\_url":"https://avatars.githubusercontent.com/u/16xxx343?v=3"\` ... } ### [](#xml-for-configuring-oauth2-authorization-code-example)XML for Configuring OAuth2 Authorization Code Example The following code shows how to configure OAuth2 Authorization Code in XML: ```xml ``` ### [](#configure-oauth2-authorization-scopes)Configure OAuth2 Authorization Scopes Scopes in OAuth are like security roles. Configure scopes for the OAuth2 Authorization code grant type in the **Scopes** field by defining a comma-separated list of OAuth scopes available in the authentication server. 1. In Studio, select the HTTP **Request** operation from your flow. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element. 3. Set **Authentication** to **Authorization code grant type**. 4. Set **Scopes** to `access_user_details, read_user_files`. ![Configure Scopes field for OAuth Authentication](/mulesoft/current/en-us/http-connector/latest/_images/http-oauth-scopes.png) 5. Click **OK**. In the **Configuration XML** editor, the `scopes` configuration looks like this: ```xml ``` ### [](#configure-oauth2-authorization-custom-parameters)Configure OAuth2 Authorization Custom Parameters There are OAuth implementations that require or allow extra query parameters to be sent when calling the Authentication URL of the OAS. Configure these parameters for the OAuth2 authorization code grant type in the **Custom parameters** field: 1. In Studio, select the HTTP **Request** operation from your flow. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element. 3. Set **Authentication** to **Authorization code grant type**. 4. Set the following fields: - **External callback url**: `http://myapp.mycompany.com:8082/callback` - **Local authorization url**: `http://localhost:8082/login` - **Authorization url**: `https://github.com/login/oauth/authorize` - **Client id**: Client ID from your GitHub account - **Client secret**: Client secret from your GitHub account - **Token url**: `https://github.com/login/oauth/access_token` 5. Set **Custom parameters** to **Edit inline**. 6. Click the plus sign (**+**) to add a new custom parameter. 7. Set **Key** to `box_device_id` and **Value** to `123142`. 8. Repeat Step 6. 9. Set **Key** to `box_device_name` and **Value** to `my-phone`. ![Configure Custom Parameters field for OAuth Authentication](/mulesoft/current/en-us/http-connector/latest/_images/http-oauth-customparameter.png) 10. Click **OK**. In the **Configuration XML** editor, the `oauth:custom-parameter` configuration looks like this: ```xml ``` ### [](#configure-oauth2-authorization-redirect-uri)Configure OAuth2 Authorization Redirect URI The [OAuth 2.0 specification](https://datatracker.ietf.org/doc/html/rfc6749) describes checking the redirect URI from the destination site of the redirect. The OAuth authentication server uses the URL to provide the authentication code to the Mule server for retrieving the access token. If you provide this URL, Mule creates an endpoint at the URL for storing the authentication code unless there’s already an endpoint registered to manually extract the authorization code. To override the redirect URI (external `redirect_uri`), configure the external redirect URI in the **External callback url** field, which is useful for actions such as deploying applications to CloudHub. When you configure authentication, you can optionally configure the **Local callback url** field as well. For CloudHub, Mule has to create an endpoint with a format similar to the following: `https://.cloudhub.io/` To instruct Mule to create the endpoint for CloudHub in the correct format, include the **External callback url** field in your OAuth2 authorization code grant type configuration. ### [](#configure-oauth2-authorization-extract-parameters)Configure OAuth2 Authorization Extract Parameters After you obtain an authorization code from the authentication server, OAuth requests an access token from the token URL of the server. The format of the response to the token URL is not defined in the OAuth specification. Each implementation can return different response formats. By default, Mule expects the response to be in JSON format. When this is the case, HTTP requests know how to extract the required information, as long as the following fields are specified: - **Response access token** The JSON field is `access_token`. - **Response refresh token** The JSON field is `refresh_token`. - **Response expires in** The JSON field is `expires_in`. When the response is in JSON format, the parameters are automatically extracted and you can use [DataWeave expressions](https://docs.mulesoft.com/mule-runtime/latest/dataweave) to reference these values in the response to the token URL. When the response is not in JSON format, then you must first configure the connector so that it knows how to extract these values. In the following example, HTTP Connector expects the response to have a `Content-Type` of `application/x-www-form-urlencoded`, so the body of the response is transformed into a map in the payload. You extract the values from the map through DataWeave expressions, such as `#[payload.access_token]` (the default value for the **Response access token** and **Response refresh token**). 1. In Studio, select the HTTP **Request** operation from your flow and in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Authorization code grant type**. 3. Verify the default options for the following fields: - **Response access token**: `#[payload.access_token]` - **Response refresh token**: `#[payload.refresh_token]` - **Response expires in**: `#[payload.expires_in]` ![Configure Response access token](/mulesoft/current/en-us/http-connector/latest/_images/http-oauth-extractparameters.png) 1. Click **OK**. In the **Configuration XML** editor, the `responseAccessToken`, `responseRefreshToken` and `responseExpiresIn` configurations look like this: ```xml ``` ### [](#configure-oauth2-authorization-refresh-token-when)Configure OAuth2 Authorization Refresh Token When The access token you obtain from the token URL eventually expires. The length of time the token is valid depends on the authentication server implementation. After the access token expires, instead of going through the whole process once again, you can retrieve a new access token by using the refresh access token provided by the token URL response. Mule manages this behavior automatically. By default, when an HTTP request is executed, if the response has a status code of 401, Mule calls the token URL and gets a new access token. You can configure when Mule performs one of these requests to obtain a new access token using a [DataWeave expression](https://docs.mulesoft.com/mule-runtime/latest/dataweave). The expression is evaluated against the response of the HTTP Request call. 1. In Studio, select the HTTP **Request** operation from your flow and in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Authorization code grant type**. 3. Set **Request Token When** to **Expression**. 4. In the expression box, add the following DataWeave expression: `#[payload.response.status == 'unauthorized']` ![Configure Response Token When field for OAuth Authentication](/mulesoft/current/en-us/http-connector/latest/_images/http-oauth-refreshtoken.png) In the **Configuration XML** editor, the `refreshTokenWhen` configuration looks like this: ```xml ``` When a request authorization fails, the response contains an XML node named `status` with value `'unauthorized'`. In the previous example, the DataWeave expression evaluates that condition. When the condition evaluates to true, Mule sends a request to the token URL to retrieve a new access token. ### [](#configure-https-for-oauth-authorization)Configure HTTPS for OAuth Authorization When you need to use HTTPS for the communication with the authentication server, such as in a production environment, apply HTTPS encoding to the OAuth credentials in all requests, including those for the: - **Local authorization url** - **Authorization url** - **Redirect url** - **Token url** To configure HTTPS for OAuth Authorization code grant type: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **TLS Configuration** to **Global Reference**. ![TLS Configuration field set to Global reference](/mulesoft/current/en-us/http-connector/latest/_images/http-oauth-tls-1.png) 3. Click the green plus sign (**+**) next to the field to create a new TLS context. 4. For **Trust Store Configuration**, set the following fields: - **Path**: `your_trust_store` - **Password**: `your_password` 5. For **Key Store Configuration**, set the following fields: - **Path**: `your_keystore_path` - **Key Password**: `your_key_password` - **Password**: `your_password` ![TLS Context global configuration settings window](/mulesoft/current/en-us/http-connector/latest/_images/http-oauth-tls-2.png) 1. Click **OK**. In the **Configuration XML** editor, the `tls:context`, `tls:trust-store` and `tls:key-store` configurations look like this: ```xml ``` ## [](#oauth2-client-authentication)Configure OAuth2 Client Credentials Grant Type Authentication The OAuth authentication server (OAS) is a server that holds the resources that are protected by OAuth. For example, the Box server provides an API with OAuth authentication. Note that HTTP Connector supports only OAuth 2.0. The client application (CA) is the server that tries to access a protected resource that belongs to a resource owner (RO). For example, a Mule server tries to access the resources that belong to a Box user, and the resources are in a Box server. In this case, the RO is also the CA. This means that the CA is implicitly authorized by the RO, which makes the whole procedure a lot simpler. The following diagram illustrates the relationship between both CA and OAS: ![OAuth2 dance between CA and OAS](/mulesoft/current/en-us/http-connector/latest/_images/http-authentication-diagram-4.png) To access protected resources: 1. The CA must register an app to the OAS server. When this occurs, the OAS assigns credentials to the CA that it can later use to identify itself: `client ID` and `client secret`. The OAS must also provide a `Token URL`, to which the CA can later send HTTP requests to retrieve an `access token` that is required when accessing the protected resources. 2. The CA makes a request to the `Token URL` of the OAS, containing its client ID to prove its identity. As a response, the OAS grants it an `access token`. 3. With the access token, the CA is now free to access the protected resources in the OAS as long as it includes the access token in the requests. Depending on the policies defined by the OAS, the token may eventually expire. Client credentials grant type is meant to be used by a client application to grant access to an application on behalf of itself, rather than on behalf of resource owner in the OAS. To get an access token, all you need is the application credentials. To configure the OAuth2 authorization code grant type for the HTTP **Request** operation, set the **Authentication** field to **Client credentials grant type**: 1. In Studio, select the HTTP Request Configuration global element where you want to use the OAuth client credentials grant type. 2. Set **Authentication** to **Client credentials grant type**. 3. Set the following fields: - **Client id** The client ID that GitHub provided when you registered the app. - **Client secret** The client secret that GitHub provided when you registered the app. - **Scopes** Scopes in OAuth are like security roles. - **Token URL** The Mule client app sends the token to the token URL. ![Client credentials grant type configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-oauthcc-authentication-1.png)
Although the Client id and Client secret fields support using variables, the connector doesn’t support changing these values dynamically during each flow execution. The configured credentials must remain static. If you require multiple sets of client credentials, it is recommended to create a separate configuration for each client.
1. Click **OK**. When the Mule app is deployed, it tries to retrieve an access token. If the Mule app is not able to retrieve an access token, deployment fails. ### [](#xml-for-configuring-client-credentials-grant-type-authentication)XML for Configuring Client Credentials Grant Type Authentication The following code shows how to configure client credentials grant type authentication in XML: ```xml ``` ### [](#configure-oauth2-client-credential-extract-parameters)Configure OAuth2 Client Credential Extract Parameters The same behavior of extracting parameters from the token URL that applies to OAuth2 authorization code grant type applies to the client credentials grant type as well: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Client credentials grant type**. 3. Verify the default options for the following fields: - **Response access token**: `#[payload.access_token]` - **Response refresh token**: `#[payload.refresh_token]` - **Response expires in**: `#[payload.expires_in]` ![Configure Response access token](/mulesoft/current/en-us/http-connector/latest/_images/http-oauthcc-extractparameters.png) 1. Click **OK**. In the **Configuration XML** editor, the `responseAccessToken`, `responseRefreshToken` and `responseExpiresIn` configurations look like this: ```xml ``` ### [](#configure-oauth2-client-credential-refresh-access-token-when)Configure OAuth2 Client Credential Refresh Access Token When The same behavior of extracting parameters from the token URL that applies to OAuth2 authorization code grant type applies to the client credentials grant type as well: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Client credentials grant type**. 3. Set **Request Token When** to **Expression**. 4. In the expression box, add the following DataWeave expression: `#[payload.response.status == 'unauthorized']` ![Configure Response Token When field for OAuth2 Client credentials grant type](/mulesoft/current/en-us/http-connector/latest/_images/http-oauthcc-refreshtoken.png) 1. Click **OK**. In the **Configuration XML** editor, the `refreshTokenWhen` configuration looks like this: ```xml ``` ## [](#configure-a-token-manager)Configure a Token Manager To access authorization information for client credentials and authorization codes, configure a token manager: 1. In Studio, select the HTTP **Request** operation from your flow and, in the properties editor for **Connector Configuration**, click the plus sign (**+**). 2. Set **Authentication** to **Authorization code grant type**. 3. Set **Token manager** to **Edit inline**. 4. Click the plus sign (**+**) to create a new configuration that references an object store. ![Configure Token manager](/mulesoft/current/en-us/http-connector/latest/_images/http-oauth-tokenmanager-1.png) 1. Click **OK**. In the **Configuration XML** editor, the `tokenManager-ref` attribute references a `token-manager-config` element like this: ```xml ``` ### [](#token-manager-access-authorization)Token Manager - Access Authorization After you have a token manager associated with an authorization grant type,you can use OAuth module operations anywhere in your Mule app flows to access information from an OAuth authorization. If you use client credentials or an authorization code with a single resource owner, use the following OAuth module operations in a flow. These operations provide access to the OAuth authorization information from a token manager: ```xml ``` If you use an authorization code with multiple resource owners, use the following OAuth module operations: ```xml ``` #### [](#token-manager-examples)Token Manager Examples The following table includes examples of how to retrieve information from a token manager. Place these OAuth module operations in your flow after the HTTP **Request** operation that manages your OAuth authentication:
Function Result

<oauth:retrieve-access-token tokenManager="tokenManagerConfig" target="accessToken"/>

accessToken value accessible through vars.accessToken from DataWeave.

<oauth:retrieve-access-token tokenManager="tokenManagerConfig" resourceOwnerId="Peter" target="accessToken"/>

accessToken value for the resource owner identified with the ID Peter accessible through vars.accessToken from DataWeave.

<oauth:retrieve-refresh-token tokenManager="tokenManagerConfig" target="refreshToken"/>

refreshToken value accessible through vars.refreshToken from DataWeave.

<oauth:retrieve-expires-in tokenManager="tokenManagerConfig" target="expiresIn"/>

Expires in value accessible through vars.expiresIn from DataWeave.

<oauth:retrieve-state tokenManager="tokenManagerConfig" target="state"/>

State used for the authorization URL accessible through vars.state from DataWeave.

<oauth:retrieve-custom-token-response-param tokenManager="tokenManagerConfig" key="a_custom_param_name" target="customParam"/>

Custom parameter extracted from the token URL response accessible through vars.customParam from DataWeave.

<oauth:retrieve-custom-token-response-param tokenManager="tokenManagerConfig" resourceOwnerId="Peter" key="a_custom_param_name" target="customParam"/>

Custom parameter extracted from the token URL response for resource owner Peter accessible through vars.customParam from DataWeave.

### [](#configure-token-manager-access-token-invalidation)Configure Token Manager Access Token Invalidation When using a token manager, you can block a particular resource owner: 1. In Studio, drag the OAuth module **Invalidate oauth context** operation to your flow. 2. In the properties editor, set the token manager to point to the same token manager that your HTTP **Request** operation references when managing OAuth authentication. 3. Set **Resource owner id** to an expression that points to the resource owner you want to clear, for example, `#[vars.resourceOwnerId]`. ![Configure Token manager](/mulesoft/current/en-us/http-connector/latest/_images/http-oauth-tokenmanager-2.png) In the **Configuration XML** editor, the `invalidate-oauth-context` configuration looks like this: ```xml ``` The **Invalidate oauth context** operation removes all of the OAuth information stored in the token manager. When using multiple resource owners with a single token manager, if you want to clear only the OAuth information of one resource owner, then specify the resource owner ID in the Invalidate OAuth Context element. ```xml ``` ### [](#configure-token-manager-object-store)Configure Token Manager Object Store By default, the token manager uses an in-memory object store to store credentials. You can configure the token manager object store by using the **Object store** field. For further information about object stores, refer to the documentation about [configuring a custom object store](https://docs.mulesoft.com/object-store-connector/latest/object-store-to-define-a-new-os). ## [](#access-resources-on-behalf-of-several-users)Access Resources on Behalf of Several Users When you need to access resources on behalf of several users, use SDK Connectors instead of using HTTP Connector in conjunction with the OAuth module. ## [](#see-also)See Also - [HTTP Connector Overview](https://docs.mulesoft.com/http-connector/latest/) - [HTTP Connector XML Reference](https://docs.mulesoft.com/http-connector/latest/http-connector-xml-reference) - [Object Store V2](https://docs.mulesoft.com/object-store/) # Configure HTTP Request Operation The Anypoint Connector for HTTP (HTTP Connector) **Request** operation enables you to consume an external HTTP service using the default `GET` method. Otherwise, you can choose what methods the operation accepts: - The `GET` and `OPTIONS` methods do not send the payload in the request (the body of the HTTP request is empty). - The `CONNECT`, `DELETE`, `PATCH`, `POST`, and `PUT` methods send the message payload as the body of the HTTP request. After the HTTP **Request** operation sends an HTTP request, the connector receives an HTTP response and passes it to the next element in the Mule app’s flow. The HTTP response indicates success or failure, using a variety of status codes. You can also customize how the operation generates HTTP responses in the connector operation global configuration. By default, the operation sends the Mule message payload as the HTTP request body but you can customize it using a DataWeave script or expression. In addition to the body of the request, you can configure: - Request and response size limits - Headers - Query parameters - URI parameters - A map of multiple headers or parameters ## [](#configure-http-request-connection)Configure HTTP Request Connection To use an HTTP **Request** operation, you must set a request global configuration with a connection provider to a host URI, which can include a path. You can additionally configure a receiving port and a communication protocol. - **Host** Indicates where the requests are sent. Additionally, it can be a host name or an IP. - **Port** Indicates where the requests are sent. - **Protocol** Indicates the protocol for communication, either HTTP for standard connections or HTTPS for TLS secure connections. To enable secure connections through HTTPS, you must define a TLS configuration context in the connection and provide: - A keystore for the server - A truststore if you need two-way authentication To learn about TLS configuration, refer to the [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) documentation. Additionally, you can configure the **Authentication** field with the following types: - **Basic authentication** - **Digest authentication** - **Ntlm authentication** (NT LAN Manager) To learn about authentication types and examples, refer to the [Configure Authentication for HTTP Requests](https://docs.mulesoft.com/http-connector/1.10/http-authentication) documentation. The following example shows how to configure the HTTP **Request** connection in Studio: 1. In the **Mule Palette** view, select **HTTP > Request**. 2. Drag **Request** to the Studio canvas. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Request** in the app. 4. Set **Host** to `localhost` and **Port** to `8081`: ![HTTP Request global configuration window with Host field set to localhost and Port field to 8081](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-1.png) 1. Set **TLS configuration** to **Edit inline**. 2. In the **Trust Store Configuration** section, set **Path** to `keystore.jks` and **Password** to `Mypassword`: ![Trust Store Configuration window with Path field set to keystore.jks and Password field to Mypassword](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-2.png) 1. Set **Authentication** to **Basic authentication**. 2. Set **Username** to `testuser` and **Password** to `Mypassword`. ![Authentication field set to Basic authentication and User field set to testuser and Password field to Mypassword](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-3.png) 1. Click **OK**. 2. In the HTTP **Request** configuration screen, set **Path** to `/testpath`: In the **Configuration XML** editor, the `host`, `port`, `path`, `trust-store`, and `authentication` configurations look like this example: ```xml ``` ## [](#configure-http-request-and-response-size-limits)Configure HTTP Request and Response Size Limits By default, Mule defines maximum values for the HTTP request size, response size, and request/response header size. However, you can change these values by modifying the following properties in the `wrapper.conf` file:
Name Property Description Default Value (in bytes)

Request Header Size

mule.http.headerSectionSize

Maximum size in bytes accepted for the HTTP request header section (request line + headers)

8192

Response Header Size

mule.http.client.headerSectionSize

Maximum size in bytes accepted for the HTTP response header section (response line + headers)

8192

Request Size

org.glassfish.grizzly.nio.transport.TCPNIOTransport.max-receive-buffer-size

Maximum size of the receive buffer that controls the number of unread bytes to hold and reflects the maximum number of unacknowledged bytes to send.

1048576 (1MB)

Response Size

org.glassfish.grizzly.nio.transport.TCPNIOTransport.max-send-buffer-size

Maximum size of the send buffer that controls the outgoing packages until there is an acknowledgment from the receiving systems.

1048576 (1MB)

You can also change the maximum values for the server response headers, server request headers, and client request headers by modifying the following system properties in the `wrapper.conf` file:
Name Property Description Default Value

Server Response Headers

mule.http.MAX_SERVER_RESPONSE_HEADERS

Maximum amount of headers allowed on a response sent from the HTTP server.

100

Server Request Headers

mule.http.MAX_SERVER_REQUEST_HEADERS

Maximum amount of headers allowed on a request sent to the HTTP server.

100

Client Request Headers

mule.http.MAX_CLIENT_REQUEST_HEADERS

Maximum amount of headers allowed on a request sent by the HTTP client.

100

There is no such Max Client Response Header system property as there is no maximum limit for client HTTP response headers. To learn more about how to set system properties in the `wrapper.conf` file, refer to the [Set System Properties in the wrapper.conf File](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system#set-properties) documentation. ## [](#configure-headers)Configure Headers You add headers to an HTTP request at one of two levels: - **Headers** At the HTTP **Request** operation level - **Default headers** At the HTTP **Request** global configuration level Configure default headers at the HTTP global configuration level to avoid specifying every header on every single request. With this configuration, those headers are added to every outbound request, alongside any headers you configure at the HTTP **Request** operation level. Some parameters, including the default headers, also accept expressions, allowing you to use dynamic values. The following example shows how to configure the **Headers** field at the HTTP **Request** operation level in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, at the **Request** section, select the **Headers** tab. 3. Click the plus sign (**+**) to add a new header. 4. In the **Name** column, change **"Key"** to `"HeaderName1"`. 5. In the **Value** column, change **"Value"** to `"HeaderValue1"`. ![Headers configuration at HTTP Request operation level](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-4.png) In the **Configuration XML** editor, the `headers` configuration looks like this: ```xml ``` You can use DataWeave expressions to add headers as well: 1. In the HTTP **Request** operation configuration window, select the **Headers** tab. 2. Click **fx** to switch to literal mode. 3. In the box located in the right section of the **fx** button, add the DataWeave expression `[{'HeaderName1' : 'HeaderValue1'}]`. ![Headers configuration at HTTP Request operation level with DataWeave expression](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-5.png) In the **Configuration XML** editor, the `headers` configuration looks like this: ```xml ``` The following example shows how to configure the **Default headers** field at the HTTP **Request** global configuration level in Studio: 1. Select the HTTP **Request** operation from your flow. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Request** in the app. If a configuration is already created, click the edit button instead. 3. Click **Settings**. 4. Set **Default headers** to **Edit inline**. 5. Click the plus sign (**+**) to add a new header. 6. Set **Key** to `x-csrf-token`. 7. Set **Value** to `Fetch`. ![Default headers configuration at HTTP Request global connection](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-6.png) 1. Click **Finish**. In the **Configuration XML** editor, the `default-headers` configuration looks like this: ```xml ``` The following example shows how to configure default headers with DataWeave expressions, allowing you to use dynamic values: 1. In the **Default headers** configuration window. 2. For **Value**, click **fx** to switch to literal mode. 3. Set **Value** to `#[vars.role]`. ![Default headers configuration at HTTP Request global connection](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-7.png) In the **Configuration XML** editor, the `default-headers` configuration looks like this: ```xml ``` Using DataWeave expressions in a configuration element constitutes a dynamic configuration. Each time a Mule app uses an HTTP **Request** operation, all expressions in the configuration are evaluated, and for each set of distinct values, a new configuration instance is created and initialized.
For HTTP Connector, use default headers with small value expressions. Otherwise, every single evaluation returns a different value and creates several instances of the HTTP client, consuming valuable resources and negatively affecting performance.
In such cases, configure headers with expressions at the HTTP **Request** operation level: ```xml #[{'custom-role':vars.role}] ``` ## [](#configure-query-parameters)Configure Query Parameters To configure query parameters for an HTTP request, follow these steps: 1. In Studio, select the HTTP **Request** operation from your flow. 2. In **General**, at the **Request** section, select the **Query Parameters** tab. 3. Click the plus sign (**+**) to add a parameter to the request. 4. In the **Name** column, change **"Key"** to `"Keyquery"`. 5. In the **Value** column, change **"Value"** to `"Valuequery"`. ![Query parameters configuration with Key field set to Keyqueryand Value field set to Valuequery](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-8.png) In the **Configuration XML** editor, the `query-params` configuration looks like this: ```xml ``` You can use DataWeave expressions to add query parameters as well: 1. In the HTTP **Request** operation configuration window, select the **Query Parameters** tab. 2. Click **fx** to switch to literal mode. 3. In the box located in the right section of the **fx** button, add the DataWeave expression `[{'Keyquery' : 'Valuequery'}]`. ![Query parameters configuration with DataWeave expression](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-9.png) In the **Configuration XML** editor, the `query-params` configuration looks like this: ```xml ``` ## [](#configure-uri-parameters)Configure URI Parameters Configure URI parameters when you want to use a placeholder, such as `/customer/{customerId}`, in the path of your request. The following example shows how to configure the **URI Parameters** field in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, set **Path** to `/customer/{customerID}`. 3. Select the **URI Parameters** tab. 4. Click the plus sign (**+**) to add a new URI parameter. 5. In the **Name** column, change **"Key"** to `"customerID"`. 6. In the **Value** column, change **"Value"** to `"20"`. ![URI Query parameters configuration with Key field set to customerID and Value field set to 20](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-10.png) In the **Configuration XML** editor, the `uri-params` configuration looks like this: ```xml ``` You can use DataWeave expressions to add URI parameters as well: 1. In the HTTP **Request** operation configuration window, select the **URI Parameters** tab. 2. Click **fx** to switch to literal mode. 3. In the box located in the right section of the **fx** button, add the DataWeave expression `[{'customerID' : '20'}]`. ![URI Query parameters configuration with DataWeave expression](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-11.png) In the **Configuration XML** editor, the `uri-params` configuration looks like this: ```xml ``` When the Mule app runs, it performs a `GET` request to: `http://www.example.com/customer/20`. ## [](#configure-dynamic-parameters-and-headers)Configure Dynamic Parameters and Headers When designing your application, if you don’t know how many parameters or headers an HTTP request might need, use DataWeave expressions and a variable map to dynamically assign parameters or headers to the HTTP request. To set headers dynamically, create a variable map and assign the variable values using DataWeave. Then, use that variable to set up the headers of your request. For example, with a variable map named `customMap`, you set up the following headers for the request: `#[vars.customMap ++ {'HeaderName1' : 'HeaderValue1'}]` To set URI parameters dynamically, use a DataWeave expression that returns a map of the parameters. For example, follow these steps: 1. Set **Path** to `` `/test/{p1}/{p2} ``.\` 2. In **General**, at **Request** section, click the **URI Parameters** tab. 3. Click the **fx** button to enter literal mode. 4. Set the following expression `vars.customMap ++ {'p2': 'customer'}`. 5. Before the **Request** operation, add a **Set Variable** operation. 6. Set **Name** to `customMap`. 7. Set **Value** to the expression `{'p1': 'some'}`. The XML looks like this: ```xml ``` If you trigger this flow, the request operation sends a request to the path `/test/some/customer`. HTTP Connector resolves parameters for each request, and evaluates DataWeave expressions in the context of the current message, in the order specified in the request. If a single parameter is defined more than once, the latest value is used. ## [](#send-form-parameters)Send Form Parameters To send form parameters in a `POST` request, follow these steps: 1. In Studio, select the HTTP **Request** operation from your flow. 2. In **General**, set **Method** to **POST**. 3. In **Body**, construct the payload of the Mule message as `application/x-www-form-urlencoded` with the names and the values of the parameters to send, for example: `[output application/x-www-form-urlencoded --- {'key1':'value1', 'key2':'value2'}` ![Body configuration with DataWeave expression](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-12.png) In the **Configuration XML** editor, the `body` configuration looks like this: ```xml ``` The HTTP **Request** operation sends a POST request to the host location. The HTTP request contains `Content-Type: application/x-www-form-urlencoded` and the body is `key1=value1&key2=value2`. ## [](#configure-round-robin-requests)Configure Round-Robin Requests The HTTP **Request** operation connects to configured hosts using round-robin DNS. Mule resolves all IP addresses associated with the specified host and performs load balancing by distributing the requests across all returned IPs. When the operation connects to resources that require authentication, the external service must replicate session information between IP addresses within the host of your service to avoid request rejection. If the external resource does not manage sticky sessions, add the service host name to the `mule.http.disableRoundRobin` system property. The HTTP request won’t use round-robin DNS to connect to the configured host. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.disableRoundRobin=serverhostname.com` ## [](#configure-response-validator)Configure Response Validator When the HTTP **Request** operation receives an HTTP response, the operation validates the response through the response status code. By default, HTTP Connector throws an HTTP error response when the status code is 400 or above. Consequently, if the server returns a 404 (Resource Not Found) or a 500 (Internal Server Error) a failure occurs and the connector triggers the error handling. Two ASCII `..` full stop characters define the range of failure status codes, which means that you can configure a range in a status code validator for example `200..399`. In XML looks like this: ```xml ``` Any value from 500 through 599 is considered a failure and raises an error. If the HTTP response has any other status code value, it’s considered a success. The HTTP **Request** operation adds the following attributes to the Mule message when receiving an HTTP response: - `attributes.statusCode` Code representing the status of the HTTP response - `attributes.reasonPhrase` A phrase describing the reasoning behind the HTTP response For a more detailed example of an HTTP response body during an HTTP request call, refer to the [HTTP Error Response example](https://docs.mulesoft.com/mule-runtime/latest/mule-error-concept#http-request-error) documentation. In the HTTP **Request** operation configuration, you can customize HTTP responses by configuring the **Response validator** field to any of these options: - **None** Uses the default validator, which throws an error when the status code is greater than or equal to 400. - **Expression or Bean reference** Uses a DataWeave expression or bean reference to define the status code. - **Failure status coded validator** Defines failure status codes that throw errors. - **Success status code validator** Defines status codes that indicate success. The following example shows how to configure the **Response validator** field in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, click the **Response** tab. 3. Set **Response validator** to **Success status code validator**. 4. In **Values**, add the list of acceptable status codes, separated by commas, such as `200,201`. If the HTTP response returned has any other status value, the operation fails and raises an error. ![Response validator field set to Success status code validator](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-13.png) In the **Configuration XML** editor, the `response-validator` configuration looks like this: ```xml ``` You can also configure Global Element Properties for the response validator: 1. In Studio, open the **HTTP Request configuration** window. 2. Select **Settings**. 3. Set **Response validator** to **Success status code validator**. 4. In **Values**, add the list of acceptable status codes, separated by commas, such as `200,201`. If the HTTP response returned has any other status value, the operation fails and raises an error. 5. Click **OK**. ## [](#configure-a-target-variable)Configure a Target Variable By default, the body of an HTTP request is taken from the `[payload]` of the incoming Mule message and the HTTP response is sent as the `[payload]` of the output Mule message. You can change this behavior for the HTTP **Request** operation, either in the **Body** field section or by updating the value of the **Target Variable** field. This value specifies a location other than payload for the output data, such as a variable. The following example shows how to configure the **Target Variable** field in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, select the **Advanced** tab. 3. Set **Target Variable** to `testvariable`. 4. Set **Target Value** to `testvalue`. ![Target variable and Target value configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-14.png) In the **Configuration XML** editor, the `target` and `targetValue` configurations look like this example: ```xml ``` ## [](#configure-request-streaming-mode)Configure Request Streaming Mode When HTTP Connector manages request bodies, the connector considers the type of data to send. You can configure the HTTP **Request** operation to send HTTP requests in chunks. By default, if the payload type is stream, the operation uses the streaming mechanism to send HTTP requests. To control this behavior, configure the **Request streaming mode** field to any of these options: - **ALWAYS** Always enable streaming regardless of the payload type. - **AUTO** (default) The behavior depends on the payload type. If the payload is a stream, streaming is enabled. Otherwise, it is disabled. - **NEVER** Never stream, even if the payload is a stream. When streaming, the HTTP request does not contain the `Content-Length` header. The request contains the `Transfer-Encoding` header and sends the body in chunks until the stream is fully consumed. The following example shows how to configure the **Request streaming mode** field in Studio: 1. In the **Mule Palette** view, select **HTTP > Request**. 2. Drag **Request** to the Studio canvas. 3. Set **Path** to `/path`. 4. In the HTTP **Request** operation configuration screen, click the **Request** tab. 5. Set **Request streaming mode** to `ALWAYS`. ![HTTP Request configuration window with Request streaming mode field set to ALWAYS](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-15.png) In the **Configuration XML** editor, the `requestStreamingMode` configuration looks like this: ```xml ``` ### [](#configure-the-request-streaming-system-property)Configure the Request Streaming System Property Setting **Request streaming mode** to `ALWAYS` causes the Mule app to send HTTP requests in chunks, but the configuration doesn’t imply that the Mule app streams the payload internally. The HTTP **Request** operation needs all the data in memory before sending HTTP requests. Therefore, if the Mule app needs to send a very large request body, the Mule app can generate a high memory consumption, and eventually cause an out-of-memory error. To prevent this issue, Mule provides the `mule.http.requestStreaming.enable` system property to enable internal request streaming. If you configure this system property, the HTTP **Request** operation starts sending the request body before all of the data is in memory. Therefore, the Mule app won’t need as much memory as it would need if you don’t configure this property. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.requestStreaming.enable=true` The default value of this property depends on the Mule runtime version. For Mule 4.4 and earlier, the property defaults to `false`. For Mule 4.5 and later, the property defaults to `true`. You can also configure the internal buffer `mule.http.requestStreaming.bufferSize` system property for the streaming mechanism. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.requestStreaming.bufferSize=value` To learn how to set system properties in Anypoint Studio or for on-premises deployments, refer to the [system properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. ## [](#configure-response-streaming)Configure Response Streaming When requesting a large payload, you can choose to stream the response by selecting the **Stream response** field in the HTTP **Request** global configuration. By default, the **Stream response** box is deselected (`false`). When you select this box (`true`), you enable Mule to manage the HTTP response as a stream by saving chunks to an in-memory buffer. You can also reconfigure the **Response buffer size** default of `1024` to a larger value; however, to avoid buffering issues, it’s important to consume responses when streaming. The following example shows how to configure the **Request streaming mode** and **Response buffer size** fields in Studio: 1. In the **Mule Palette** view, select **HTTP > Request**. 2. Drag **Request** to the Studio canvas. 3. Set **Path** to `/path`. 4. Click the plus sign (**+**) to open the HTTP Request global configuration. 5. Select the **Stream response** box. 6. Set **Response buffer size** to \`100:. ![HTTP Request configuration window with Stream response field selected and Response buffer size field set to 100](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-16.png) In the **Configuration XML** editor, the `streamResponse` and `responseBufferSize` configurations look like this example: ```xml ``` When you enable response streaming and the response is chunked, the HTTP service uses internal structures to store data chunks. If the next processor to the HTTP **Request** operation needs the whole response in order to operate, the processor could be blocked from reading from those internal structures. Subsequently, if the server doesn’t send any chunks and it doesn’t close the connection, such a processor could be blocked forever. To avoid this situation, the HTTP service establishes a timeout to wait for data to be read. The default timeout value is 20 seconds. You can change the timeout value with the system property `mule.http.responseStreaming.pipeReadTimeoutMillis`. Tuning this value is not recommended. ## [](#configure-retry-mechanisms)Configure Retry Mechanisms The HTTP **Request** operation does not use the reconnection strategy for retries. The reconnection strategy is a mechanism that Mule SDK uses to reestablish connections when a `ConnectionException` error occurs. This mechanism does not affect connections to an HTTP service created by the HTTP **Request** operation. To learn more about connections, refer to the [Mule SDK Connections](https://docs.mulesoft.com/mule-sdk/latest/connections) documentation. HTTP Connector uses a retry mechanism that enables you to configure how many times it attempts to consume an external HTTP service. The connector uses this mechanism to reconnect an HTTP client with an HTTP service. HTTP Connector does not manage TCP connections, so this mechanism does not reconnect sockets. To configure how many times the HTTP **Request** operation can retry consuming an external HTTP service (_retries_), you can use either: - The **Until Successful** scope component - The built-in retry mechanism in the HTTP **Request** operation ### [](#configure-retry-mechanism-with-until-successful-scope)Configure Retry Mechanism with Until Successful Scope The **Until Successful** scope processes the components within the scope, in order, until they succeed or exhaust the maximum number of retries. Enclosing the HTTP **Request** operation in this scope enables you to configure the **Max Retries** and **Milliseconds Between Retries** fields. The following example shows how to configure the retry mechanism with the **Until Successful** scope in Studio: 1. In the **Mule Palette** view, select **Core > Until Successful**. 2. Drag the **Until Successful** scope component to the Studio canvas. 3. Set **Max retries** to `5`. 4. Set **Milliseconds Between Retries** to `10000`. 5. In the **Mule Palette** view, select **HTTP > Request**. 6. Drag **Request** into the **Until Successful** scope component. ![Until Successful scope configuration with HTTP Request operation](/mulesoft/current/en-us/http-connector/1.10/_images/http-request-17.png) In the **Configuration XML** editor, the `until-successful`, `maxRetries`, and `millisBetweenRetries` configurations look like this example: ```xml ``` To learn more about this scope, refer to the [Until Successful Scope](https://docs.mulesoft.com/mule-runtime/latest/until-successful-scope) documentation. ### [](#configure-built-in-retry-mechanism)Configure Built-In Retry Mechanism When the HTTP **Request** operation receives an error of type `Remotely Closed`, the operation automatically retries the idempotent methods `PUT`, `DELETE`, `GET`, `HEAD`, `OPTIONS`, and `TRACE` three times before the retry fails. You can configure two system properties to customize this mechanism: - `mule.http.client.maxRetries=5` This system property enables you to configure the number of retries before the HTTP **Request** operation fails. Additionally, you can set the system property value to zero to avoid using the built-in mechanism. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.client.maxRetries=5` - `mule.http.client.retryOnAllMethods=true` This system property extends the built-in mechanism to all the methods, and not only the idempotent ones. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.client.retryOnAllMethods=true` To learn how to set system properties, refer to the [System Properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. To understand why nonidempotent methods, such as `POST`, aren’t retried by default, refer to [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230). ## [](#see-also)See Also - [Mule 4 Thread Pools and Tuning apps](https://docs.mulesoft.com/mule-runtime/latest/execution-engine#thread-pools-and-tuning-apps) - [HTTP Request Attributes Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation#HttpRequestAttributes) - [HTTP Response Attributes Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation#HttpResponseAttributes) # Configure HTTP Request Operation The Anypoint Connector for HTTP (HTTP Connector) **Request** operation enables you to consume an external HTTP service using the default `GET` method. Otherwise, you can choose what methods the operation accepts: - The `GET` and `OPTIONS` methods do not send the payload in the request (the body of the HTTP request is empty). - The `CONNECT`, `DELETE`, `PATCH`, `POST`, and `PUT` methods send the message payload as the body of the HTTP request. After the HTTP **Request** operation sends an HTTP request, the connector receives an HTTP response and passes it to the next element in the Mule app’s flow. The HTTP response indicates success or failure, using a variety of status codes. You can also customize how the operation generates HTTP responses in the connector operation global configuration. By default, the operation sends the Mule message payload as the HTTP request body but you can customize it using a DataWeave script or expression. In addition to the body of the request, you can configure: - Request and response size limits - Headers - Query parameters - URI parameters - A map of multiple headers or parameters ## [](#configure-http-request-connection)Configure HTTP Request Connection To use an HTTP **Request** operation, you must set a request global configuration with a connection provider to a host URI, which can include a path. You can additionally configure a receiving port and a communication protocol. - **Host** Indicates where the requests are sent. Additionally, it can be a host name or an IP. - **Port** Indicates where the requests are sent. - **Protocol** Indicates the protocol for communication, either HTTP for standard connections or HTTPS for TLS secure connections. To enable secure connections through HTTPS, you must define a TLS configuration context in the connection and provide: - A keystore for the server - A truststore if you need two-way authentication To learn about TLS configuration, refer to the [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) documentation. Additionally, you can configure the **Authentication** field with the following types: - **Basic authentication** - **Digest authentication** - **Ntlm authentication** (NT LAN Manager) To learn about authentication types and examples, refer to the [Configure Authentication for HTTP Requests](https://docs.mulesoft.com/http-connector/1.11/http-authentication) documentation. The following example shows how to configure the HTTP **Request** connection in Studio: 1. In the **Mule Palette** view, select **HTTP > Request**. 2. Drag **Request** to the Studio canvas. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Request** in the app. 4. Set **Host** to `localhost` and **Port** to `8081`: ![HTTP Request global configuration window with Host field set to localhost and Port field to 8081](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-1.png) 1. Set **TLS configuration** to **Edit inline**. 2. In the **Trust Store Configuration** section, set **Path** to `keystore.jks` and **Password** to `Mypassword`: ![Trust Store Configuration window with Path field set to keystore.jks and Password field to Mypassword](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-2.png) 1. Set **Authentication** to **Basic authentication**. 2. Set **Username** to `testuser` and **Password** to `Mypassword`. ![Authentication field set to Basic authentication and User field set to testuser and Password field to Mypassword](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-3.png) 1. Click **OK**. 2. In the HTTP **Request** configuration screen, set **Path** to `/testpath`: In the **Configuration XML** editor, the `host`, `port`, `path`, `trust-store`, and `authentication` configurations look like this example: ```xml ``` ## [](#configure-http-request-and-response-size-limits)Configure HTTP Request and Response Size Limits By default, Mule defines maximum values for the HTTP request size, response size, and request/response header size. However, you can change these values by modifying the following properties in the `wrapper.conf` file:
Name Property Description Default Value (in bytes)

Request Header Size

mule.http.headerSectionSize

Maximum size in bytes accepted for the HTTP request header section (request line + headers)

8192

Response Header Size

mule.http.client.headerSectionSize

Maximum size in bytes accepted for the HTTP response header section (response line + headers)

8192

Request Size

org.glassfish.grizzly.nio.transport.TCPNIOTransport.max-receive-buffer-size

Maximum size of the receive buffer that controls the number of unread bytes to hold and reflects the maximum number of unacknowledged bytes to send.

1048576 (1MB)

Response Size

org.glassfish.grizzly.nio.transport.TCPNIOTransport.max-send-buffer-size

Maximum size of the send buffer that controls the outgoing packages until there is an acknowledgment from the receiving systems.

1048576 (1MB)

You can also change the maximum values for the server response headers, server request headers, and client request headers by modifying the following system properties in the `wrapper.conf` file:
Name Property Description Default Value

Server Response Headers

mule.http.MAX_SERVER_RESPONSE_HEADERS

Maximum amount of headers allowed on a response sent from the HTTP server.

100

Server Request Headers

mule.http.MAX_SERVER_REQUEST_HEADERS

Maximum amount of headers allowed on a request sent to the HTTP server.

100

Client Request Headers

mule.http.MAX_CLIENT_REQUEST_HEADERS

Maximum amount of headers allowed on a request sent by the HTTP client.

100

There is no such Max Client Response Header system property as there is no maximum limit for client HTTP response headers. To learn more about how to set system properties in the `wrapper.conf` file, refer to the [Set System Properties in the wrapper.conf File](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system#set-properties) documentation. ## [](#configure-headers)Configure Headers You add headers to an HTTP request at one of two levels: - **Headers** At the HTTP **Request** operation level - **Default headers** At the HTTP **Request** global configuration level Configure default headers at the HTTP global configuration level to avoid specifying every header on every single request. With this configuration, those headers are added to every outbound request, alongside any headers you configure at the HTTP **Request** operation level. Some parameters, including the default headers, also accept expressions, allowing you to use dynamic values. The following example shows how to configure the **Headers** field at the HTTP **Request** operation level in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, at the **Request** section, select the **Headers** tab. 3. Click the plus sign (**+**) to add a new header. 4. In the **Name** column, change **"Key"** to `"HeaderName1"`. 5. In the **Value** column, change **"Value"** to `"HeaderValue1"`. ![Headers configuration at HTTP Request operation level](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-4.png) In the **Configuration XML** editor, the `headers` configuration looks like this: ```xml ``` You can use DataWeave expressions to add headers as well: 1. In the HTTP **Request** operation configuration window, select the **Headers** tab. 2. Click **fx** to switch to literal mode. 3. In the box located in the right section of the **fx** button, add the DataWeave expression `[{'HeaderName1' : 'HeaderValue1'}]`. ![Headers configuration at HTTP Request operation level with DataWeave expression](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-5.png) In the **Configuration XML** editor, the `headers` configuration looks like this: ```xml ``` The following example shows how to configure the **Default headers** field at the HTTP **Request** global configuration level in Studio: 1. Select the HTTP **Request** operation from your flow. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Request** in the app. If a configuration is already created, click the edit button instead. 3. Click **Settings**. 4. Set **Default headers** to **Edit inline**. 5. Click the plus sign (**+**) to add a new header. 6. Set **Key** to `x-csrf-token`. 7. Set **Value** to `Fetch`. ![Default headers configuration at HTTP Request global connection](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-6.png) 1. Click **Finish**. In the **Configuration XML** editor, the `default-headers` configuration looks like this: ```xml ``` The following example shows how to configure default headers with DataWeave expressions, allowing you to use dynamic values: 1. In the **Default headers** configuration window. 2. For **Value**, click **fx** to switch to literal mode. 3. Set **Value** to `#[vars.role]`. ![Default headers configuration at HTTP Request global connection](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-7.png) In the **Configuration XML** editor, the `default-headers` configuration looks like this: ```xml ``` Using DataWeave expressions in a configuration element constitutes a dynamic configuration. Each time a Mule app uses an HTTP **Request** operation, all expressions in the configuration are evaluated, and for each set of distinct values, a new configuration instance is created and initialized.
For HTTP Connector, use default headers with small value expressions. Otherwise, every single evaluation returns a different value and creates several instances of the HTTP client, consuming valuable resources and negatively affecting performance.
In such cases, configure headers with expressions at the HTTP **Request** operation level: ```xml #[{'custom-role':vars.role}] ``` ## [](#configure-query-parameters)Configure Query Parameters To configure query parameters for an HTTP request, follow these steps: 1. In Studio, select the HTTP **Request** operation from your flow. 2. In **General**, at the **Request** section, select the **Query Parameters** tab. 3. Click the plus sign (**+**) to add a parameter to the request. 4. In the **Name** column, change **"Key"** to `"Keyquery"`. 5. In the **Value** column, change **"Value"** to `"Valuequery"`. ![Query parameters configuration with Key field set to Keyqueryand Value field set to Valuequery](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-8.png) In the **Configuration XML** editor, the `query-params` configuration looks like this: ```xml ``` You can use DataWeave expressions to add query parameters as well: 1. In the HTTP **Request** operation configuration window, select the **Query Parameters** tab. 2. Click **fx** to switch to literal mode. 3. In the box located in the right section of the **fx** button, add the DataWeave expression `[{'Keyquery' : 'Valuequery'}]`. ![Query parameters configuration with DataWeave expression](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-9.png) In the **Configuration XML** editor, the `query-params` configuration looks like this: ```xml ``` ## [](#configure-uri-parameters)Configure URI Parameters Configure URI parameters when you want to use a placeholder, such as `/customer/{customerId}`, in the path of your request. The following example shows how to configure the **URI Parameters** field in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, set **Path** to `/customer/{customerID}`. 3. Select the **URI Parameters** tab. 4. Click the plus sign (**+**) to add a new URI parameter. 5. In the **Name** column, change **"Key"** to `"customerID"`. 6. In the **Value** column, change **"Value"** to `"20"`. ![URI Query parameters configuration with Key field set to customerID and Value field set to 20](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-10.png) In the **Configuration XML** editor, the `uri-params` configuration looks like this: ```xml ``` You can use DataWeave expressions to add URI parameters as well: 1. In the HTTP **Request** operation configuration window, select the **URI Parameters** tab. 2. Click **fx** to switch to literal mode. 3. In the box located in the right section of the **fx** button, add the DataWeave expression `[{'customerID' : '20'}]`. ![URI Query parameters configuration with DataWeave expression](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-11.png) In the **Configuration XML** editor, the `uri-params` configuration looks like this: ```xml ``` When the Mule app runs, it performs a `GET` request to: `http://www.example.com/customer/20`. ## [](#configure-dynamic-parameters-and-headers)Configure Dynamic Parameters and Headers When designing your application, if you don’t know how many parameters or headers an HTTP request might need, use DataWeave expressions and a variable map to dynamically assign parameters or headers to the HTTP request. To set headers dynamically, create a variable map and assign the variable values using DataWeave. Then, use that variable to set up the headers of your request. For example, with a variable map named `customMap`, you set up the following headers for the request: `#[vars.customMap ++ {'HeaderName1' : 'HeaderValue1'}]` To set URI parameters dynamically, use a DataWeave expression that returns a map of the parameters. For example, follow these steps: 1. Set **Path** to `` `/test/{p1}/{p2} ``.\` 2. In **General**, at **Request** section, click the **URI Parameters** tab. 3. Click the **fx** button to enter literal mode. 4. Set the following expression `vars.customMap ++ {'p2': 'customer'}`. 5. Before the **Request** operation, add a **Set Variable** operation. 6. Set **Name** to `customMap`. 7. Set **Value** to the expression `{'p1': 'some'}`. The XML looks like this: ```xml ``` If you trigger this flow, the request operation sends a request to the path `/test/some/customer`. HTTP Connector resolves parameters for each request, and evaluates DataWeave expressions in the context of the current message, in the order specified in the request. If a single parameter is defined more than once, the latest value is used. ## [](#send-form-parameters)Send Form Parameters To send form parameters in a `POST` request, follow these steps: 1. In Studio, select the HTTP **Request** operation from your flow. 2. In **General**, set **Method** to **POST**. 3. In **Body**, construct the payload of the Mule message as `application/x-www-form-urlencoded` with the names and the values of the parameters to send, for example: `[output application/x-www-form-urlencoded --- {'key1':'value1', 'key2':'value2'}` ![Body configuration with DataWeave expression](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-12.png) In the **Configuration XML** editor, the `body` configuration looks like this: ```xml ``` The HTTP **Request** operation sends a POST request to the host location. The HTTP request contains `Content-Type: application/x-www-form-urlencoded` and the body is `key1=value1&key2=value2`. ## [](#configure-round-robin-requests)Configure Round-Robin Requests The HTTP **Request** operation connects to configured hosts using round-robin DNS. Mule resolves all IP addresses associated with the specified host and performs load balancing by distributing the requests across all returned IPs. When the operation connects to resources that require authentication, the external service must replicate session information between IP addresses within the host of your service to avoid request rejection. If the external resource does not manage sticky sessions, add the service host name to the `mule.http.disableRoundRobin` system property. The HTTP request won’t use round-robin DNS to connect to the configured host. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.disableRoundRobin=serverhostname.com` ## [](#configure-response-validator)Configure Response Validator When the HTTP **Request** operation receives an HTTP response, the operation validates the response through the response status code. By default, HTTP Connector throws an HTTP error response when the status code is 400 or above. Consequently, if the server returns a 404 (Resource Not Found) or a 500 (Internal Server Error) a failure occurs and the connector triggers the error handling. Two ASCII `..` full stop characters define the range of failure status codes, which means that you can configure a range in a status code validator for example `200..399`. In XML looks like this: ```xml ``` Any value from 500 through 599 is considered a failure and raises an error. If the HTTP response has any other status code value, it’s considered a success. The HTTP **Request** operation adds the following attributes to the Mule message when receiving an HTTP response: - `attributes.statusCode` Code representing the status of the HTTP response - `attributes.reasonPhrase` A phrase describing the reasoning behind the HTTP response For a more detailed example of an HTTP response body during an HTTP request call, refer to the [HTTP Error Response example](https://docs.mulesoft.com/mule-runtime/latest/mule-error-concept#http-request-error) documentation. In the HTTP **Request** operation configuration, you can customize HTTP responses by configuring the **Response validator** field to any of these options: - **None** Uses the default validator, which throws an error when the status code is greater than or equal to 400. - **Expression or Bean reference** Uses a DataWeave expression or bean reference to define the status code. - **Failure status coded validator** Defines failure status codes that throw errors. - **Success status code validator** Defines status codes that indicate success. The following example shows how to configure the **Response validator** field in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, click the **Response** tab. 3. Set **Response validator** to **Success status code validator**. 4. In **Values**, add the list of acceptable status codes, separated by commas, such as `200,201`. If the HTTP response returned has any other status value, the operation fails and raises an error. ![Response validator field set to Success status code validator](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-13.png) In the **Configuration XML** editor, the `response-validator` configuration looks like this: ```xml ``` You can also configure Global Element Properties for the response validator: 1. In Studio, open the **HTTP Request configuration** window. 2. Select **Settings**. 3. Set **Response validator** to **Success status code validator**. 4. In **Values**, add the list of acceptable status codes, separated by commas, such as `200,201`. If the HTTP response returned has any other status value, the operation fails and raises an error. 5. Click **OK**. ## [](#configure-a-target-variable)Configure a Target Variable By default, the body of an HTTP request is taken from the `[payload]` of the incoming Mule message and the HTTP response is sent as the `[payload]` of the output Mule message. You can change this behavior for the HTTP **Request** operation, either in the **Body** field section or by updating the value of the **Target Variable** field. This value specifies a location other than payload for the output data, such as a variable. The following example shows how to configure the **Target Variable** field in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, select the **Advanced** tab. 3. Set **Target Variable** to `testvariable`. 4. Set **Target Value** to `testvalue`. ![Target variable and Target value configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-14.png) In the **Configuration XML** editor, the `target` and `targetValue` configurations look like this example: ```xml ``` ## [](#configure-request-streaming-mode)Configure Request Streaming Mode When HTTP Connector manages request bodies, the connector considers the type of data to send. You can configure the HTTP **Request** operation to send HTTP requests in chunks. By default, if the payload type is stream, the operation uses the streaming mechanism to send HTTP requests. To control this behavior, configure the **Request streaming mode** field to any of these options: - **ALWAYS** Always enable streaming regardless of the payload type. - **AUTO** (default) The behavior depends on the payload type. If the payload is a stream, streaming is enabled. Otherwise, it is disabled. - **NEVER** Never stream, even if the payload is a stream. When streaming, the HTTP request does not contain the `Content-Length` header. The request contains the `Transfer-Encoding` header and sends the body in chunks until the stream is fully consumed. The following example shows how to configure the **Request streaming mode** field in Studio: 1. In the **Mule Palette** view, select **HTTP > Request**. 2. Drag **Request** to the Studio canvas. 3. Set **Path** to `/path`. 4. In the HTTP **Request** operation configuration screen, click the **Request** tab. 5. Set **Request streaming mode** to `ALWAYS`. ![HTTP Request configuration window with Request streaming mode field set to ALWAYS](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-15.png) In the **Configuration XML** editor, the `requestStreamingMode` configuration looks like this: ```xml ``` ### [](#configure-the-request-streaming-system-property)Configure the Request Streaming System Property Setting **Request streaming mode** to `ALWAYS` causes the Mule app to send HTTP requests in chunks, but the configuration doesn’t imply that the Mule app streams the payload internally. The HTTP **Request** operation needs all the data in memory before sending HTTP requests. Therefore, if the Mule app needs to send a very large request body, the Mule app can generate a high memory consumption, and eventually cause an out-of-memory error. To prevent this issue, Mule provides the `mule.http.requestStreaming.enable` system property to enable internal request streaming. If you configure this system property, the HTTP **Request** operation starts sending the request body before all of the data is in memory. Therefore, the Mule app won’t need as much memory as it would need if you don’t configure this property. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.requestStreaming.enable=true` The default value of this property depends on the Mule runtime version. For Mule 4.4 and earlier, the property defaults to `false`. For Mule 4.5 and later, the property defaults to `true`. You can also configure the internal buffer `mule.http.requestStreaming.bufferSize` system property for the streaming mechanism. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.requestStreaming.bufferSize=value` To learn how to set system properties in Anypoint Studio or for on-premises deployments, refer to the [system properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. ## [](#configure-response-streaming)Configure Response Streaming When requesting a large payload, you can choose to stream the response by selecting the **Stream response** field in the HTTP **Request** global configuration. By default, the **Stream response** box is deselected (`false`). When you select this box (`true`), you enable Mule to manage the HTTP response as a stream by saving chunks to an in-memory buffer. The **Response buffer size** value defaults to `-1`, which means that the buffer size isn’t limited and that the connector uses a system-defined default. You can set a positive value (in bytes) to limit the buffer, however, to avoid buffering issues, it’s important to consume responses when streaming. The following example shows how to configure the **Request streaming mode** and **Response buffer size** fields in Studio: 1. In the **Mule Palette** view, select **HTTP > Request**. 2. Drag **Request** to the Studio canvas. 3. Set **Path** to `/path`. 4. Click the plus sign (**+**) to open the HTTP Request global configuration. 5. Select the **Stream response** box. 6. Set **Response buffer size** to \`100:. ![HTTP Request configuration window with Stream response field selected and Response buffer size field set to 100](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-16.png) In the **Configuration XML** editor, the `streamResponse` and `responseBufferSize` configurations look like this example: ```xml ``` When you enable response streaming and the response is chunked, the HTTP service uses internal structures to store data chunks. If the next processor to the HTTP **Request** operation needs the whole response in order to operate, the processor could be blocked from reading from those internal structures. Subsequently, if the server doesn’t send any chunks and it doesn’t close the connection, such a processor could be blocked forever. To avoid this situation, the HTTP service establishes a timeout to wait for data to be read. The default timeout value is 20 seconds. You can change the timeout value with the system property `mule.http.responseStreaming.pipeReadTimeoutMillis`. Tuning this value is not recommended. ## [](#configure-retry-mechanisms)Configure Retry Mechanisms The HTTP **Request** operation does not use the reconnection strategy for retries. The reconnection strategy is a mechanism that Mule SDK uses to reestablish connections when a `ConnectionException` error occurs. This mechanism does not affect connections to an HTTP service created by the HTTP **Request** operation. To learn more about connections, refer to the [Mule SDK Connections](https://docs.mulesoft.com/mule-sdk/latest/connections) documentation. HTTP Connector uses a retry mechanism that enables you to configure how many times it attempts to consume an external HTTP service. The connector uses this mechanism to reconnect an HTTP client with an HTTP service. HTTP Connector does not manage TCP connections, so this mechanism does not reconnect sockets. To configure how many times the HTTP **Request** operation can retry consuming an external HTTP service (_retries_), you can use either: - The **Until Successful** scope component - The built-in retry mechanism in the HTTP **Request** operation ### [](#configure-retry-mechanism-with-until-successful-scope)Configure Retry Mechanism with Until Successful Scope The **Until Successful** scope processes the components within the scope, in order, until they succeed or exhaust the maximum number of retries. Enclosing the HTTP **Request** operation in this scope enables you to configure the **Max Retries** and **Milliseconds Between Retries** fields. The following example shows how to configure the retry mechanism with the **Until Successful** scope in Studio: 1. In the **Mule Palette** view, select **Core > Until Successful**. 2. Drag the **Until Successful** scope component to the Studio canvas. 3. Set **Max retries** to `5`. 4. Set **Milliseconds Between Retries** to `10000`. 5. In the **Mule Palette** view, select **HTTP > Request**. 6. Drag **Request** into the **Until Successful** scope component. ![Until Successful scope configuration with HTTP Request operation](/mulesoft/current/en-us/http-connector/1.11/_images/http-request-17.png) In the **Configuration XML** editor, the `until-successful`, `maxRetries`, and `millisBetweenRetries` configurations look like this example: ```xml ``` To learn more about this scope, refer to the [Until Successful Scope](https://docs.mulesoft.com/mule-runtime/latest/until-successful-scope) documentation. ### [](#configure-built-in-retry-mechanism)Configure Built-In Retry Mechanism When the HTTP **Request** operation receives an error of type `Remotely Closed`, the operation automatically retries the idempotent methods `PUT`, `DELETE`, `GET`, `HEAD`, `OPTIONS`, and `TRACE` three times before the retry fails. You can configure two system properties to customize this mechanism: - `mule.http.client.maxRetries=5` This system property enables you to configure the number of retries before the HTTP **Request** operation fails. Additionally, you can set the system property value to zero to avoid using the built-in mechanism. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.client.maxRetries=5` - `mule.http.client.retryOnAllMethods=true` This system property extends the built-in mechanism to all the methods, and not only the idempotent ones. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.client.retryOnAllMethods=true` To learn how to set system properties, refer to the [System Properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. To understand why nonidempotent methods, such as `POST`, aren’t retried by default, refer to [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230). ## [](#see-also)See Also - [Mule 4 Thread Pools and Tuning apps](https://docs.mulesoft.com/mule-runtime/latest/execution-engine#thread-pools-and-tuning-apps) - [HTTP Request Attributes Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation#HttpRequestAttributes) - [HTTP Response Attributes Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation#HttpResponseAttributes) # Configure HTTP Request Operation The Anypoint Connector for HTTP (HTTP Connector) **Request** operation enables you to consume an external HTTP service using the default `GET` method. Otherwise, you can choose what methods the operation accepts: - The `GET` and `OPTIONS` methods do not send the payload in the request (the body of the HTTP request is empty). - The `CONNECT`, `DELETE`, `PATCH`, `POST`, and `PUT` methods send the message payload as the body of the HTTP request. After the HTTP **Request** operation sends an HTTP request, the connector receives an HTTP response and passes it to the next element in the Mule app’s flow. The HTTP response indicates success or failure, using a variety of status codes. You can also customize how the operation generates HTTP responses in the connector operation global configuration. By default, the operation sends the Mule message payload as the HTTP request body but you can customize it using a DataWeave script or expression. In addition to the body of the request, you can configure: - Request and response size limits - Headers - Query parameters - URI parameters - A map of multiple headers or parameters ## [](#configure-http-request-connection)Configure HTTP Request Connection To use an HTTP **Request** operation, you must set a request global configuration with a connection provider to a host URI, which can include a path. You can additionally configure a receiving port and a communication protocol. - **Host** Indicates where the requests are sent. Additionally, it can be a host name or an IP. - **Port** Indicates where the requests are sent. - **Protocol** Indicates the protocol for communication, either HTTP for standard connections or HTTPS for TLS secure connections. To enable secure connections through HTTPS, you must define a TLS configuration context in the connection and provide: - A keystore for the server - A truststore if you need two-way authentication To learn about TLS configuration, refer to the [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration) documentation. Additionally, you can configure the **Authentication** field with the following types: - **Basic authentication** - **Digest authentication** - **Ntlm authentication** (NT LAN Manager) To learn about authentication types and examples, refer to the [Configure Authentication for HTTP Requests](https://docs.mulesoft.com/http-connector/latest/http-authentication) documentation. The following example shows how to configure the HTTP **Request** connection in Studio: 1. In the **Mule Palette** view, select **HTTP > Request**. 2. Drag **Request** to the Studio canvas. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Request** in the app. 4. Set **Host** to `localhost` and **Port** to `8081`: ![HTTP Request global configuration window with Host field set to localhost and Port field to 8081](/mulesoft/current/en-us/http-connector/latest/_images/http-request-1.png) 1. Set **TLS configuration** to **Edit inline**. 2. In the **Trust Store Configuration** section, set **Path** to `keystore.jks` and **Password** to `Mypassword`: ![Trust Store Configuration window with Path field set to keystore.jks and Password field to Mypassword](/mulesoft/current/en-us/http-connector/latest/_images/http-request-2.png) 1. Set **Authentication** to **Basic authentication**. 2. Set **Username** to `testuser` and **Password** to `Mypassword`. ![Authentication field set to Basic authentication and User field set to testuser and Password field to Mypassword](/mulesoft/current/en-us/http-connector/latest/_images/http-request-3.png) 1. Click **OK**. 2. In the HTTP **Request** configuration screen, set **Path** to `/testpath`: In the **Configuration XML** editor, the `host`, `port`, `path`, `trust-store`, and `authentication` configurations look like this example: ```xml ``` ## [](#configure-http-request-and-response-size-limits)Configure HTTP Request and Response Size Limits By default, Mule defines maximum values for the HTTP request size, response size, and request/response header size. However, you can change these values by modifying the following properties in the `wrapper.conf` file:
Name Property Description Default Value (in bytes)

Request Header Size

mule.http.headerSectionSize

Maximum size in bytes accepted for the HTTP request header section (request line + headers)

8192

Response Header Size

mule.http.client.headerSectionSize

Maximum size in bytes accepted for the HTTP response header section (response line + headers)

8192

Request Size

org.glassfish.grizzly.nio.transport.TCPNIOTransport.max-receive-buffer-size

Maximum size of the receive buffer that controls the number of unread bytes to hold and reflects the maximum number of unacknowledged bytes to send.

1048576 (1MB)

Response Size

org.glassfish.grizzly.nio.transport.TCPNIOTransport.max-send-buffer-size

Maximum size of the send buffer that controls the outgoing packages until there is an acknowledgment from the receiving systems.

1048576 (1MB)

You can also change the maximum values for the server response headers, server request headers, and client request headers by modifying the following system properties in the `wrapper.conf` file:
Name Property Description Default Value

Server Response Headers

mule.http.MAX_SERVER_RESPONSE_HEADERS

Maximum amount of headers allowed on a response sent from the HTTP server.

100

Server Request Headers

mule.http.MAX_SERVER_REQUEST_HEADERS

Maximum amount of headers allowed on a request sent to the HTTP server.

100

Client Request Headers

mule.http.MAX_CLIENT_REQUEST_HEADERS

Maximum amount of headers allowed on a request sent by the HTTP client.

100

There is no such Max Client Response Header system property as there is no maximum limit for client HTTP response headers. To learn more about how to set system properties in the `wrapper.conf` file, refer to the [Set System Properties in the wrapper.conf File](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system#set-properties) documentation. ## [](#configure-headers)Configure Headers You add headers to an HTTP request at one of two levels: - **Headers** At the HTTP **Request** operation level - **Default headers** At the HTTP **Request** global configuration level Configure default headers at the HTTP global configuration level to avoid specifying every header on every single request. With this configuration, those headers are added to every outbound request, alongside any headers you configure at the HTTP **Request** operation level. Some parameters, including the default headers, also accept expressions, allowing you to use dynamic values. The following example shows how to configure the **Headers** field at the HTTP **Request** operation level in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, at the **Request** section, select the **Headers** tab. 3. Click the plus sign (**+**) to add a new header. 4. In the **Name** column, change **"Key"** to `"HeaderName1"`. 5. In the **Value** column, change **"Value"** to `"HeaderValue1"`. ![Headers configuration at HTTP Request operation level](/mulesoft/current/en-us/http-connector/latest/_images/http-request-4.png) In the **Configuration XML** editor, the `headers` configuration looks like this: ```xml ``` You can use DataWeave expressions to add headers as well: 1. In the HTTP **Request** operation configuration window, select the **Headers** tab. 2. Click **fx** to switch to literal mode. 3. In the box located in the right section of the **fx** button, add the DataWeave expression `[{'HeaderName1' : 'HeaderValue1'}]`. ![Headers configuration at HTTP Request operation level with DataWeave expression](/mulesoft/current/en-us/http-connector/latest/_images/http-request-5.png) In the **Configuration XML** editor, the `headers` configuration looks like this: ```xml ``` The following example shows how to configure the **Default headers** field at the HTTP **Request** global configuration level in Studio: 1. Select the HTTP **Request** operation from your flow. 2. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Request** in the app. If a configuration is already created, click the edit button instead. 3. Click **Settings**. 4. Set **Default headers** to **Edit inline**. 5. Click the plus sign (**+**) to add a new header. 6. Set **Key** to `x-csrf-token`. 7. Set **Value** to `Fetch`. ![Default headers configuration at HTTP Request global connection](/mulesoft/current/en-us/http-connector/latest/_images/http-request-6.png) 1. Click **Finish**. In the **Configuration XML** editor, the `default-headers` configuration looks like this: ```xml ``` The following example shows how to configure default headers with DataWeave expressions, allowing you to use dynamic values: 1. In the **Default headers** configuration window. 2. For **Value**, click **fx** to switch to literal mode. 3. Set **Value** to `#[vars.role]`. ![Default headers configuration at HTTP Request global connection](/mulesoft/current/en-us/http-connector/latest/_images/http-request-7.png) In the **Configuration XML** editor, the `default-headers` configuration looks like this: ```xml ``` Using DataWeave expressions in a configuration element constitutes a dynamic configuration. Each time a Mule app uses an HTTP **Request** operation, all expressions in the configuration are evaluated, and for each set of distinct values, a new configuration instance is created and initialized.
For HTTP Connector, use default headers with small value expressions. Otherwise, every single evaluation returns a different value and creates several instances of the HTTP client, consuming valuable resources and negatively affecting performance.
In such cases, configure headers with expressions at the HTTP **Request** operation level: ```xml #[{'custom-role':vars.role}] ``` ## [](#configure-host-header)Configure the Host Header By default, when no port is specified in the host configuration, the HTTP **Request** operation includes the default port (`80` for HTTP or `443` for HTTPS) in the autogenerated `Host` header. For example, an HTTPS request to `api.example.com` sends `Host: api.example.com:443`. Some external services or web application firewalls reject a `Host` header that includes the default port. To control `Host` header generation, use one of these options: - Explicitly set `Host` without the port in the operation’s **Headers** field: ```xml #[{'Host': 'api.example.com'}] ``` - For Mule runtime 4.5 and later with HTTP Connector 1.10.3 and later, omit the default port by setting the system property `-Dmule.http.connector.omitDefaultPortInHostHeader=true`. See [Set System Properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) for configuration instructions. - Configure the complete URL directly in the **Request** operation’s **URL** field to influence `Host` header generation. ## [](#configure-query-parameters)Configure Query Parameters To configure query parameters for an HTTP request, follow these steps: 1. In Studio, select the HTTP **Request** operation from your flow. 2. In **General**, at the **Request** section, select the **Query Parameters** tab. 3. Click the plus sign (**+**) to add a parameter to the request. 4. In the **Name** column, change **"Key"** to `"Keyquery"`. 5. In the **Value** column, change **"Value"** to `"Valuequery"`. ![Query parameters configuration with Key field set to Keyqueryand Value field set to Valuequery](/mulesoft/current/en-us/http-connector/latest/_images/http-request-8.png) In the **Configuration XML** editor, the `query-params` configuration looks like this: ```xml ``` You can use DataWeave expressions to add query parameters as well: 1. In the HTTP **Request** operation configuration window, select the **Query Parameters** tab. 2. Click **fx** to switch to literal mode. 3. In the box located in the right section of the **fx** button, add the DataWeave expression `[{'Keyquery' : 'Valuequery'}]`. ![Query parameters configuration with DataWeave expression](/mulesoft/current/en-us/http-connector/latest/_images/http-request-9.png) In the **Configuration XML** editor, the `query-params` configuration looks like this: ```xml ``` ## [](#configure-uri-parameters)Configure URI Parameters Configure URI parameters when you want to use a placeholder, such as `/customer/{customerId}`, in the path of your request. The following example shows how to configure the **URI Parameters** field in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, set **Path** to `/customer/{customerID}`. 3. Select the **URI Parameters** tab. 4. Click the plus sign (**+**) to add a new URI parameter. 5. In the **Name** column, change **"Key"** to `"customerID"`. 6. In the **Value** column, change **"Value"** to `"20"`. ![URI Query parameters configuration with Key field set to customerID and Value field set to 20](/mulesoft/current/en-us/http-connector/latest/_images/http-request-10.png) In the **Configuration XML** editor, the `uri-params` configuration looks like this: ```xml ``` You can use DataWeave expressions to add URI parameters as well: 1. In the HTTP **Request** operation configuration window, select the **URI Parameters** tab. 2. Click **fx** to switch to literal mode. 3. In the box located in the right section of the **fx** button, add the DataWeave expression `[{'customerID' : '20'}]`. ![URI Query parameters configuration with DataWeave expression](/mulesoft/current/en-us/http-connector/latest/_images/http-request-11.png) In the **Configuration XML** editor, the `uri-params` configuration looks like this: ```xml ``` When the Mule app runs, it performs a `GET` request to: `http://www.example.com/customer/20`. ## [](#configure-dynamic-parameters-and-headers)Configure Dynamic Parameters and Headers When designing your application, if you don’t know how many parameters or headers an HTTP request might need, use DataWeave expressions and a variable map to dynamically assign parameters or headers to the HTTP request. To set headers dynamically, create a variable map and assign the variable values using DataWeave. Then, use that variable to set up the headers of your request. For example, with a variable map named `customMap`, you set up the following headers for the request: `#[vars.customMap ++ {'HeaderName1' : 'HeaderValue1'}]` To set URI parameters dynamically, use a DataWeave expression that returns a map of the parameters. For example, follow these steps: 1. Set **Path** to `` `/test/{p1}/{p2} ``.\` 2. In **General**, at **Request** section, click the **URI Parameters** tab. 3. Click the **fx** button to enter literal mode. 4. Set the following expression `vars.customMap ++ {'p2': 'customer'}`. 5. Before the **Request** operation, add a **Set Variable** operation. 6. Set **Name** to `customMap`. 7. Set **Value** to the expression `{'p1': 'some'}`. The XML looks like this: ```xml ``` If you trigger this flow, the request operation sends a request to the path `/test/some/customer`. HTTP Connector resolves parameters for each request, and evaluates DataWeave expressions in the context of the current message, in the order specified in the request. If a single parameter is defined more than once, the latest value is used. ## [](#send-form-parameters)Send Form Parameters To send form parameters in a `POST` request, follow these steps: 1. In Studio, select the HTTP **Request** operation from your flow. 2. In **General**, set **Method** to **POST**. 3. In **Body**, construct the payload of the Mule message as `application/x-www-form-urlencoded` with the names and the values of the parameters to send, for example: `[output application/x-www-form-urlencoded --- {'key1':'value1', 'key2':'value2'}` ![Body configuration with DataWeave expression](/mulesoft/current/en-us/http-connector/latest/_images/http-request-12.png) In the **Configuration XML** editor, the `body` configuration looks like this: ```xml ``` The HTTP **Request** operation sends a POST request to the host location. The HTTP request contains `Content-Type: application/x-www-form-urlencoded` and the body is `key1=value1&key2=value2`. ## [](#configure-round-robin-requests)Configure Round-Robin Requests The HTTP **Request** operation connects to configured hosts using round-robin DNS. Mule resolves all IP addresses associated with the specified host and performs load balancing by distributing the requests across all returned IPs. When the operation connects to resources that require authentication, the external service must replicate session information between IP addresses within the host of your service to avoid request rejection. If the external resource does not manage sticky sessions, add the service host name to the `mule.http.disableRoundRobin` system property. The HTTP request won’t use round-robin DNS to connect to the configured host. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.disableRoundRobin=serverhostname.com` ## [](#configure-response-validator)Configure Response Validator When the HTTP **Request** operation receives an HTTP response, the operation validates the response through the response status code. By default, HTTP Connector throws an HTTP error response when the status code is 400 or above. Consequently, if the server returns a 404 (Resource Not Found) or a 500 (Internal Server Error) a failure occurs and the connector triggers the error handling. Two ASCII `..` full stop characters define the range of failure status codes, which means that you can configure a range in a status code validator for example `200..399`. In XML looks like this: ```xml ``` Any value from 500 through 599 is considered a failure and raises an error. If the HTTP response has any other status code value, it’s considered a success. The HTTP **Request** operation adds the following attributes to the Mule message when receiving an HTTP response: - `attributes.statusCode` Code representing the status of the HTTP response - `attributes.reasonPhrase` A phrase describing the reasoning behind the HTTP response For a more detailed example of an HTTP response body during an HTTP request call, refer to the [HTTP Error Response example](https://docs.mulesoft.com/mule-runtime/latest/mule-error-concept#http-request-error) documentation. In the HTTP **Request** operation configuration, you can customize HTTP responses by configuring the **Response validator** field to any of these options: - **None** Uses the default validator, which throws an error when the status code is greater than or equal to 400. - **Expression or Bean reference** Uses a DataWeave expression or bean reference to define the status code. - **Failure status coded validator** Defines failure status codes that throw errors. - **Success status code validator** Defines status codes that indicate success. The following example shows how to configure the **Response validator** field in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, click the **Response** tab. 3. Set **Response validator** to **Success status code validator**. 4. In **Values**, add the list of acceptable status codes, separated by commas, such as `200,201`. If the HTTP response returned has any other status value, the operation fails and raises an error. ![Response validator field set to Success status code validator](/mulesoft/current/en-us/http-connector/latest/_images/http-request-13.png) In the **Configuration XML** editor, the `response-validator` configuration looks like this: ```xml ``` You can also configure Global Element Properties for the response validator: 1. In Studio, open the **HTTP Request configuration** window. 2. Select **Settings**. 3. Set **Response validator** to **Success status code validator**. 4. In **Values**, add the list of acceptable status codes, separated by commas, such as `200,201`. If the HTTP response returned has any other status value, the operation fails and raises an error. 5. Click **OK**. ## [](#configure-a-target-variable)Configure a Target Variable By default, the body of an HTTP request is taken from the `[payload]` of the incoming Mule message and the HTTP response is sent as the `[payload]` of the output Mule message. You can change this behavior for the HTTP **Request** operation, either in the **Body** field section or by updating the value of the **Target Variable** field. This value specifies a location other than payload for the output data, such as a variable. The following example shows how to configure the **Target Variable** field in Studio: 1. Select the HTTP **Request** operation from your flow. 2. In **General**, select the **Advanced** tab. 3. Set **Target Variable** to `testvariable`. 4. Set **Target Value** to `testvalue`. ![Target variable and Target value configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-request-14.png) In the **Configuration XML** editor, the `target` and `targetValue` configurations look like this example: ```xml ``` ## [](#configure-request-streaming-mode)Configure Request Streaming Mode When HTTP Connector manages request bodies, the connector considers the type of data to send. You can configure the HTTP **Request** operation to send HTTP requests in chunks. By default, if the payload type is stream, the operation uses the streaming mechanism to send HTTP requests. To control this behavior, configure the **Request streaming mode** field to any of these options: - **ALWAYS** Always enable streaming regardless of the payload type. - **AUTO** (default) The behavior depends on the payload type. If the payload is a stream, streaming is enabled. Otherwise, it is disabled. - **NEVER** Never stream, even if the payload is a stream. When streaming, the HTTP request does not contain the `Content-Length` header. The request contains the `Transfer-Encoding` header and sends the body in chunks until the stream is fully consumed. The following example shows how to configure the **Request streaming mode** field in Studio: 1. In the **Mule Palette** view, select **HTTP > Request**. 2. Drag **Request** to the Studio canvas. 3. Set **Path** to `/path`. 4. In the HTTP **Request** operation configuration screen, click the **Request** tab. 5. Set **Request streaming mode** to `ALWAYS`. ![HTTP Request configuration window with Request streaming mode field set to ALWAYS](/mulesoft/current/en-us/http-connector/latest/_images/http-request-15.png) In the **Configuration XML** editor, the `requestStreamingMode` configuration looks like this: ```xml ``` ### [](#configure-the-request-streaming-system-property)Configure the Request Streaming System Property Setting **Request streaming mode** to `ALWAYS` causes the Mule app to send HTTP requests in chunks, but the configuration doesn’t imply that the Mule app streams the payload internally. The HTTP **Request** operation needs all the data in memory before sending HTTP requests. Therefore, if the Mule app needs to send a very large request body, the Mule app can generate a high memory consumption, and eventually cause an out-of-memory error. To prevent this issue, Mule provides the `mule.http.requestStreaming.enable` system property to enable internal request streaming. If you configure this system property, the HTTP **Request** operation starts sending the request body before all of the data is in memory. Therefore, the Mule app won’t need as much memory as it would need if you don’t configure this property. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.requestStreaming.enable=true` The default value of this property depends on the Mule runtime version. For Mule 4.4 and earlier, the property defaults to `false`. For Mule 4.5 and later, the property defaults to `true`. You can also configure the internal buffer `mule.http.requestStreaming.bufferSize` system property for the streaming mechanism. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.requestStreaming.bufferSize=value` To learn how to set system properties in Anypoint Studio or for on-premises deployments, refer to the [system properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. ## [](#configure-response-streaming)Configure Response Streaming When requesting a large payload, you can choose to stream the response by selecting the **Stream response** field in the HTTP **Request** global configuration. By default, the **Stream response** box is deselected (`false`). When you select this box (`true`), you enable Mule to manage the HTTP response as a stream by saving chunks to an in-memory buffer. The **Response buffer size** value defaults to `-1`, which means that the buffer size isn’t limited and that the connector uses a system-defined default. You can set a positive value (in bytes) to limit the buffer, however, to avoid buffering issues, it’s important to consume responses when streaming. The following example shows how to configure the **Request streaming mode** and **Response buffer size** fields in Studio: 1. In the **Mule Palette** view, select **HTTP > Request**. 2. Drag **Request** to the Studio canvas. 3. Set **Path** to `/path`. 4. Click the plus sign (**+**) to open the HTTP Request global configuration. 5. Select the **Stream response** box. 6. Set **Response buffer size** to \`100:. ![HTTP Request configuration window with Stream response field selected and Response buffer size field set to 100](/mulesoft/current/en-us/http-connector/latest/_images/http-request-16.png) In the **Configuration XML** editor, the `streamResponse` and `responseBufferSize` configurations look like this example: ```xml ``` When you enable response streaming and the response is chunked, the HTTP service uses internal structures to store data chunks. If the next processor to the HTTP **Request** operation needs the whole response in order to operate, the processor could be blocked from reading from those internal structures. Subsequently, if the server doesn’t send any chunks and it doesn’t close the connection, such a processor could be blocked forever. To avoid this situation, the HTTP service establishes a timeout to wait for data to be read. The default timeout value is 20 seconds. You can change the timeout value with the system property `mule.http.responseStreaming.pipeReadTimeoutMillis`. Tuning this value is not recommended. ## [](#configure-retry-mechanisms)Configure Retry Mechanisms The HTTP **Request** operation does not use the reconnection strategy for retries. The reconnection strategy is a mechanism that Mule SDK uses to reestablish connections when a `ConnectionException` error occurs. This mechanism does not affect connections to an HTTP service created by the HTTP **Request** operation. To learn more about connections, refer to the [Mule SDK Connections](https://docs.mulesoft.com/mule-sdk/latest/connections) documentation. HTTP Connector uses a retry mechanism that enables you to configure how many times it attempts to consume an external HTTP service. The connector uses this mechanism to reconnect an HTTP client with an HTTP service. HTTP Connector does not manage TCP connections, so this mechanism does not reconnect sockets. To configure how many times the HTTP **Request** operation can retry consuming an external HTTP service (_retries_), you can use either: - The **Until Successful** scope component - The built-in retry mechanism in the HTTP **Request** operation ### [](#configure-retry-mechanism-with-until-successful-scope)Configure Retry Mechanism with Until Successful Scope The **Until Successful** scope processes the components within the scope, in order, until they succeed or exhaust the maximum number of retries. Enclosing the HTTP **Request** operation in this scope enables you to configure the **Max Retries** and **Milliseconds Between Retries** fields. The following example shows how to configure the retry mechanism with the **Until Successful** scope in Studio: 1. In the **Mule Palette** view, select **Core > Until Successful**. 2. Drag the **Until Successful** scope component to the Studio canvas. 3. Set **Max retries** to `5`. 4. Set **Milliseconds Between Retries** to `10000`. 5. In the **Mule Palette** view, select **HTTP > Request**. 6. Drag **Request** into the **Until Successful** scope component. ![Until Successful scope configuration with HTTP Request operation](/mulesoft/current/en-us/http-connector/latest/_images/http-request-17.png) In the **Configuration XML** editor, the `until-successful`, `maxRetries`, and `millisBetweenRetries` configurations look like this example: ```xml ``` To learn more about this scope, refer to the [Until Successful Scope](https://docs.mulesoft.com/mule-runtime/latest/until-successful-scope) documentation. ### [](#configure-built-in-retry-mechanism)Configure Built-In Retry Mechanism When the HTTP **Request** operation receives an error of type `Remotely Closed`, the operation automatically retries the idempotent methods `PUT`, `DELETE`, `GET`, `HEAD`, `OPTIONS`, and `TRACE` three times before the retry fails. You can configure two system properties to customize this mechanism: - `mule.http.client.maxRetries=5` This system property enables you to configure the number of retries before the HTTP **Request** operation fails. Additionally, you can set the system property value to zero to avoid using the built-in mechanism. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.client.maxRetries=5` - `mule.http.client.retryOnAllMethods=true` This system property extends the built-in mechanism to all the methods, and not only the idempotent ones. Configure this system property when starting Mule by adding: `./mule -M-Dmule.http.client.retryOnAllMethods=true` To learn how to set system properties, refer to the [System Properties](https://docs.mulesoft.com/mule-runtime/latest/mule-app-properties-system) documentation. To understand why nonidempotent methods, such as `POST`, aren’t retried by default, refer to [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230). ## [](#see-also)See Also - [Mule 4 Thread Pools and Tuning apps](https://docs.mulesoft.com/mule-runtime/latest/execution-engine#thread-pools-and-tuning-apps) - [HTTP Request Attributes Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation#HttpRequestAttributes) - [HTTP Response Attributes Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation#HttpResponseAttributes) --- product: HTTP Connector version: 1.10 --- # Configuring Basic Security Filter for HTTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Consider a Mule app that exposes an API for accessing sensitive customer information, such as personal details and order history. To secure this API, you want to implement basic security using a username and password combination. The Anypoint Platform for HTTP (HTTP Connector) **Basic Security Filter** operation enables you to enforce basic authentication. The following example illustrates how to configure the **Basic Security Filter** operation to ensure that only authorized users can access the protected API. 1. In Anypoint Studio, add an **HTTP Listener** source to your flow. This serves as the entry point for incoming API requests. 2. Drag the **Basic Security Filter** operation after the **HTTP Listener**. The operation validates the username and password provided in the request headers. 3. Select the **Basic Security Filter** operation from your flow. 4. Configure the **Basic Security Filter** operation with the authentication **Realm** and **Security providers**. 5. Continue building your Mule flow by adding the logic for handling API requests, retrieving customer information, or performing other operations. ![HTTP Basic Security Filter configuration window in Anypoint Studio](/mulesoft/current/en-us/http-connector/1.10/_images/http-basic-security.png) In the **Configuration XML**, the configuration looks like this: ```xml ``` ## See Also - [HTTP Connector Examples](https://docs.mulesoft.com/http-connector/1.10/http-connector-examples) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation) --- product: HTTP Connector version: 1.11 --- # Configuring Basic Security Filter for HTTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Consider a Mule app that exposes an API for accessing sensitive customer information, such as personal details and order history. To secure this API, you want to implement basic security using a username and password combination. The Anypoint Platform for HTTP (HTTP Connector) **Basic Security Filter** operation enables you to enforce basic authentication. The following example illustrates how to configure the **Basic Security Filter** operation to ensure that only authorized users can access the protected API. 1. In Anypoint Studio, add an **HTTP Listener** source to your flow. This serves as the entry point for incoming API requests. 2. Drag the **Basic Security Filter** operation after the **HTTP Listener**. The operation validates the username and password provided in the request headers. 3. Select the **Basic Security Filter** operation from your flow. 4. Configure the **Basic Security Filter** operation with the authentication **Realm** and **Security providers**. 5. Continue building your Mule flow by adding the logic for handling API requests, retrieving customer information, or performing other operations. ![HTTP Basic Security Filter configuration window in Anypoint Studio](/mulesoft/current/en-us/http-connector/1.11/_images/http-basic-security.png) In the **Configuration XML**, the configuration looks like this: ```xml ``` ## See Also - [HTTP Connector Examples](https://docs.mulesoft.com/http-connector/1.11/http-connector-examples) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Configuring Basic Security Filter for HTTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Consider a Mule app that exposes an API for accessing sensitive customer information, such as personal details and order history. To secure this API, you want to implement basic security using a username and password combination. The Anypoint Platform for HTTP (HTTP Connector) **Basic Security Filter** operation enables you to enforce basic authentication. The following example illustrates how to configure the **Basic Security Filter** operation to ensure that only authorized users can access the protected API. 1. In Anypoint Studio, add an **HTTP Listener** source to your flow. This serves as the entry point for incoming API requests. 2. Drag the **Basic Security Filter** operation after the **HTTP Listener**. The operation validates the username and password provided in the request headers. 3. Select the **Basic Security Filter** operation from your flow. 4. Configure the **Basic Security Filter** operation with the authentication **Realm** and **Security providers**. 5. Continue building your Mule flow by adding the logic for handling API requests, retrieving customer information, or performing other operations. ![HTTP Basic Security Filter configuration window in Anypoint Studio](/mulesoft/current/en-us/http-connector/latest/_images/http-basic-security.png) In the **Configuration XML**, the configuration looks like this: ```xml ``` ## See Also - [HTTP Connector Examples](https://docs.mulesoft.com/http-connector/latest/http-connector-examples) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation) --- product: HTTP Connector version: 1.10 --- # Configuring HTTP Polling Source > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP Connector (HTTP Connector) provides a **Polling Source** event source that executes a scheduled HTTP request to a given HTTP server. This source does not wait for an HTTP request from a user, as does the HTTP **Listener** source. In the HTTP **Polling Source** event source, you can configure: - A scheduled frequency that can be a fixed frequency or a cron expression. - The event source to split the HTTP response, so every item in the response is executed in a different execution of the flow. - How to retrieve watermarking. ## Relationship with HTTP Request Operation Because the HTTP **Polling Source** event source performs an HTTP request (such as the HTTP **Request** operation), configure the source by using HTTP request global configuration, including configuring the URL, port, base path, protocol, and any custom request configuration that your implementation requires The source executes an HTTP request and, with the resulting HTTP response, creates one or more events that trigger its flow. The following configuration example shows a polling source that polls every 10 hours. ![HTTP Polling source configuration window in Anypoint Studio](/mulesoft/current/en-us/http-connector/1.10/_images/http-polling-source.png) In the **Configuration XML** view, the ``, ``, and `` configurations look like this: ```xml ``` ## Configuring Polling Frequency Configure the schedule strategy as either a fixed frequency or cron expression in the **Scheduling strategy** (``) field. In the **Configuration XML** editor, the `` and `` configurations look like this: ```xml ``` ## Configuring Parameters In the same way that you can for the HTTP **Request** operation, you can also configure the body, headers, URI parameters, and query parameters for the HTTP **Polling Source** event source. The following example shows how to configure the **Body** (`polling-request-body`), **Headers** (`polling-request-headers`), **URI parameters** (`polling-request-uri-param`), and **Query parameters** (`polling-request-query-param`) fields with values to which you can add expressions. These expressions can depend on the watermark. In the **Configuration XML** editor, the `polling-request-body`, `polling-request-headers`, `polling-request-uri-param`, and `polling-request-query-param` configurations look like this: ```xml ``` ## Configuring Split Expressions After the HTTP **Polling Source** event source executes the HTTP request and retrieves an HTTP response, you can perform a transformation and split the HTTP response in such a way that every item in that response is executed in a different execution of the flow. For example, imagine that you poll a server that gets its data from a database, and the server returns 50 results. You want to send each result separately to the flow without splitting the response between the flow and the use of a **For each** component. To split the response, configure the **Split expression** (`splitExpression`) field. In the splitting expression, refer to the response as `payload`, as you would do after an HTTP **Request** operation. The following example shows a server that returns a JSON payload in which the items are in an array. The `set-payload` component configuration looks like this: ```xml ``` In this case, the corresponding expression to split the array is `#[payload]`. In the splitting expression, the referred `payload` is the entire response, already treated as a JSON file. Meanwhile, the `payload` referred to in the `logger` processor refers to the corresponding payload for its execution: on one execution `{'name': 'Mondi'}`, and on the other execution `{'name': 'Viena'}`). The `splitExpression` configuration looks like this: ```xml ``` The following example shows two concurrent executions of the flow after a single polling: one execution with `Mondi` and another execution with `Viena`. After 10 hours, the polling is executed again. In this example, the server returns the same result: ```xml ``` ## Configuring Watermarking Expressions In the previous simple examples, the server always returns the same HTTP response. In more complex scenarios the server needs to know that it has to send the next response. You can send headers, URI parameters, body, or query parameters, but if these parameters always contain the same values in the HTTP request, the server does not know what would be the next response. For polling scenarios like this, you implement watermarking, in which the server returns a watermark value either for the entire payload or for every item in that payload separately. For example, the watermark value can be a timestamp that refers to the entire collection, or every item could have its own timestamp. In either case, you provide a watermark expression by using the `watermark` placeholder. The expression extracts the watermark from the response and subsequently uses this watermark to send the requests to the server. You can use expressions for the body, headers, URI parameters, and query parameters values in the `watermark` placeholder. Note that in the first execution, the `watermark` placeholder value is `null`, which you might want to consider in the server or the expression where the placeholder is used. To refer to the entire payload in the watermark expression, use the `payload` placeholder. To refer to an item, use the `item` placeholder, which applies the watermarking expression each item individually. The following XML configuration example shows an HTTP **Listener** flow. In the first polling iteration, when there is no watermark, a payload is returned with a watermark value set in the `wm` property. In the second polling iteration, a watermark value is expected, so the payload is different. In this case, coming from the request’s payload: ```xml ``` The following XML configuration example shows how to extract the watermark value from the entire payload and then use the value in the body of the request. The configuration uses the HTTP **Polling Source** event source instead of the HTTP **Listener** source: ```xml ``` - The `watermarkExpression` has the `watermark` placeholder that retrieves the watermark from the property `wm` of the response. - The first polling iteration includes three executions of the flow, one execution with `{name: 'Eze'}`, another execution with `{name: 'Fabi'}`, and the last execution with `{name: 'Sofi'}`. - In the second polling iteration, which occurs five minutes later, there are two executions, one execution with `{name: 'Euge'}` and another execution with `{name: 'Juli'}`). - In the second polling iteration, which occurs five minutes later, there are two executions, one execution with `{name: 'Euge'}` and another execution with `{name: 'Juli'}`). - Afterward the third iteration, polling continues, but because the results are empty, there are no flow executions. The following XML configuration example shows how to extract the watermark value from each item and then use that value in the query parameters. The behavior depends completely on how the HTTP server uses the watermarking value: ```xml ``` ## Configuring Idempotency Expressions To avoid the concurrent execution of two flows with the same payload identification, configure idempotency for the HTTP **Polling Source** event source. This configuration ensures that payloads with the same ID are not processed concurrently. To configure idempotency for the event source, add an ID expression to retrieve the ID from the item, similar to the watermarking expression configuration. Use `payload` and `item` placeholders in the idempotency expression `idExpression`. In the following XML configuration example, the first three items execute the flow concurrently and the fourth item starts its process only after the first item finishes processing. ```xml ``` ## Configuring Response Validators Validate the responses received by configuring and using a response validator. The following XML configuration example shows a situation in which the server always returns a status code of 301, when the response validator expects a default status code between 200 and 299 and, as a result, the HTTP response always fails. This indicates that the flow does not execute, and the payload is considered valid only when the response validator defines 301 as the status code (the splitting, watermarking, and idempotency configurations are applied then): ```xml ``` ## See Also - [Configure HTTP Request Operation](https://docs.mulesoft.com/http-connector/1.10/http-request-ref) - [HTTP Connector Examples](https://docs.mulesoft.com/http-connector/1.10/http-connector-examples) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation) --- product: HTTP Connector version: 1.11 --- # Configuring HTTP Polling Source > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP Connector (HTTP Connector) provides a **Polling Source** event source that executes a scheduled HTTP request to a given HTTP server. This source does not wait for an HTTP request from a user, as does the HTTP **Listener** source. In the HTTP **Polling Source** event source, you can configure: - A scheduled frequency that can be a fixed frequency or a cron expression. - The event source to split the HTTP response, so every item in the response is executed in a different execution of the flow. - How to retrieve watermarking. ## Relationship with HTTP Request Operation Because the HTTP **Polling Source** event source performs an HTTP request (such as the HTTP **Request** operation), configure the source by using HTTP request global configuration, including configuring the URL, port, base path, protocol, and any custom request configuration that your implementation requires The source executes an HTTP request and, with the resulting HTTP response, creates one or more events that trigger its flow. The following configuration example shows a polling source that polls every 10 hours. ![HTTP Polling source configuration window in Anypoint Studio](/mulesoft/current/en-us/http-connector/1.11/_images/http-polling-source.png) In the **Configuration XML** view, the ``, ``, and `` configurations look like this: ```xml ``` ## Configuring Polling Frequency Configure the schedule strategy as either a fixed frequency or cron expression in the **Scheduling strategy** (``) field. In the **Configuration XML** editor, the `` and `` configurations look like this: ```xml ``` ## Configuring Parameters In the same way that you can for the HTTP **Request** operation, you can also configure the body, headers, URI parameters, and query parameters for the HTTP **Polling Source** event source. The following example shows how to configure the **Body** (`polling-request-body`), **Headers** (`polling-request-headers`), **URI parameters** (`polling-request-uri-param`), and **Query parameters** (`polling-request-query-param`) fields with values to which you can add expressions. These expressions can depend on the watermark. In the **Configuration XML** editor, the `polling-request-body`, `polling-request-headers`, `polling-request-uri-param`, and `polling-request-query-param` configurations look like this: ```xml ``` ## Configuring Split Expressions After the HTTP **Polling Source** event source executes the HTTP request and retrieves an HTTP response, you can perform a transformation and split the HTTP response in such a way that every item in that response is executed in a different execution of the flow. For example, imagine that you poll a server that gets its data from a database, and the server returns 50 results. You want to send each result separately to the flow without splitting the response between the flow and the use of a **For each** component. To split the response, configure the **Split expression** (`splitExpression`) field. In the splitting expression, refer to the response as `payload`, as you would do after an HTTP **Request** operation. The following example shows a server that returns a JSON payload in which the items are in an array. The `set-payload` component configuration looks like this: ```xml ``` In this case, the corresponding expression to split the array is `#[payload]`. In the splitting expression, the referred `payload` is the entire response, already treated as a JSON file. Meanwhile, the `payload` referred to in the `logger` processor refers to the corresponding payload for its execution: on one execution `{'name': 'Mondi'}`, and on the other execution `{'name': 'Viena'}`). The `splitExpression` configuration looks like this: ```xml ``` The following example shows two concurrent executions of the flow after a single polling: one execution with `Mondi` and another execution with `Viena`. After 10 hours, the polling is executed again. In this example, the server returns the same result: ```xml ``` ## Configuring Watermarking Expressions In the previous simple examples, the server always returns the same HTTP response. In more complex scenarios the server needs to know that it has to send the next response. You can send headers, URI parameters, body, or query parameters, but if these parameters always contain the same values in the HTTP request, the server does not know what would be the next response. For polling scenarios like this, you implement watermarking, in which the server returns a watermark value either for the entire payload or for every item in that payload separately. For example, the watermark value can be a timestamp that refers to the entire collection, or every item could have its own timestamp. In either case, you provide a watermark expression by using the `watermark` placeholder. The expression extracts the watermark from the response and subsequently uses this watermark to send the requests to the server. You can use expressions for the body, headers, URI parameters, and query parameters values in the `watermark` placeholder. Note that in the first execution, the `watermark` placeholder value is `null`, which you might want to consider in the server or the expression where the placeholder is used. To refer to the entire payload in the watermark expression, use the `payload` placeholder. To refer to an item, use the `item` placeholder, which applies the watermarking expression each item individually. The following XML configuration example shows an HTTP **Listener** flow. In the first polling iteration, when there is no watermark, a payload is returned with a watermark value set in the `wm` property. In the second polling iteration, a watermark value is expected, so the payload is different. In this case, coming from the request’s payload: ```xml ``` The following XML configuration example shows how to extract the watermark value from the entire payload and then use the value in the body of the request. The configuration uses the HTTP **Polling Source** event source instead of the HTTP **Listener** source: ```xml ``` - The `watermarkExpression` has the `watermark` placeholder that retrieves the watermark from the property `wm` of the response. - The first polling iteration includes three executions of the flow, one execution with `{name: 'Eze'}`, another execution with `{name: 'Fabi'}`, and the last execution with `{name: 'Sofi'}`. - In the second polling iteration, which occurs five minutes later, there are two executions, one execution with `{name: 'Euge'}` and another execution with `{name: 'Juli'}`). - In the second polling iteration, which occurs five minutes later, there are two executions, one execution with `{name: 'Euge'}` and another execution with `{name: 'Juli'}`). - Afterward the third iteration, polling continues, but because the results are empty, there are no flow executions. The following XML configuration example shows how to extract the watermark value from each item and then use that value in the query parameters. The behavior depends completely on how the HTTP server uses the watermarking value: ```xml ``` ## Configuring Idempotency Expressions To avoid the concurrent execution of two flows with the same payload identification, configure idempotency for the HTTP **Polling Source** event source. This configuration ensures that payloads with the same ID are not processed concurrently. To configure idempotency for the event source, add an ID expression to retrieve the ID from the item, similar to the watermarking expression configuration. Use `payload` and `item` placeholders in the idempotency expression `idExpression`. In the following XML configuration example, the first three items execute the flow concurrently and the fourth item starts its process only after the first item finishes processing. ```xml ``` ## Configuring Response Validators Validate the responses received by configuring and using a response validator. The following XML configuration example shows a situation in which the server always returns a status code of 301, when the response validator expects a default status code between 200 and 299 and, as a result, the HTTP response always fails. This indicates that the flow does not execute, and the payload is considered valid only when the response validator defines 301 as the status code (the splitting, watermarking, and idempotency configurations are applied then): ```xml ``` ## See Also - [Configure HTTP Request Operation](https://docs.mulesoft.com/http-connector/1.11/http-request-ref) - [HTTP Connector Examples](https://docs.mulesoft.com/http-connector/1.11/http-connector-examples) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Configuring HTTP Polling Source > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP Connector (HTTP Connector) provides a **Polling Source** event source that executes a scheduled HTTP request to a given HTTP server. This source does not wait for an HTTP request from a user, as does the HTTP **Listener** source. In the HTTP **Polling Source** event source, you can configure: - A scheduled frequency that can be a fixed frequency or a cron expression. - The event source to split the HTTP response, so every item in the response is executed in a different execution of the flow. - How to retrieve watermarking. ## Relationship with HTTP Request Operation Because the HTTP **Polling Source** event source performs an HTTP request (such as the HTTP **Request** operation), configure the source by using HTTP request global configuration, including configuring the URL, port, base path, protocol, and any custom request configuration that your implementation requires The source executes an HTTP request and, with the resulting HTTP response, creates one or more events that trigger its flow. The following configuration example shows a polling source that polls every 10 hours. ![HTTP Polling source configuration window in Anypoint Studio](/mulesoft/current/en-us/http-connector/latest/_images/http-polling-source.png) In the **Configuration XML** view, the ``, ``, and `` configurations look like this: ```xml ``` ## Configuring Polling Frequency Configure the schedule strategy as either a fixed frequency or cron expression in the **Scheduling strategy** (``) field. In the **Configuration XML** editor, the `` and `` configurations look like this: ```xml ``` ## Configuring Parameters In the same way that you can for the HTTP **Request** operation, you can also configure the body, headers, URI parameters, and query parameters for the HTTP **Polling Source** event source. The following example shows how to configure the **Body** (`polling-request-body`), **Headers** (`polling-request-headers`), **URI parameters** (`polling-request-uri-param`), and **Query parameters** (`polling-request-query-param`) fields with values to which you can add expressions. These expressions can depend on the watermark. In the **Configuration XML** editor, the `polling-request-body`, `polling-request-headers`, `polling-request-uri-param`, and `polling-request-query-param` configurations look like this: ```xml ``` ## Configuring Split Expressions After the HTTP **Polling Source** event source executes the HTTP request and retrieves an HTTP response, you can perform a transformation and split the HTTP response in such a way that every item in that response is executed in a different execution of the flow. For example, imagine that you poll a server that gets its data from a database, and the server returns 50 results. You want to send each result separately to the flow without splitting the response between the flow and the use of a **For each** component. To split the response, configure the **Split expression** (`splitExpression`) field. In the splitting expression, refer to the response as `payload`, as you would do after an HTTP **Request** operation. The following example shows a server that returns a JSON payload in which the items are in an array. The `set-payload` component configuration looks like this: ```xml ``` In this case, the corresponding expression to split the array is `#[payload]`. In the splitting expression, the referred `payload` is the entire response, already treated as a JSON file. Meanwhile, the `payload` referred to in the `logger` processor refers to the corresponding payload for its execution: on one execution `{'name': 'Mondi'}`, and on the other execution `{'name': 'Viena'}`). The `splitExpression` configuration looks like this: ```xml ``` The following example shows two concurrent executions of the flow after a single polling: one execution with `Mondi` and another execution with `Viena`. After 10 hours, the polling is executed again. In this example, the server returns the same result: ```xml ``` ## Configuring Watermarking Expressions In the previous simple examples, the server always returns the same HTTP response. In more complex scenarios the server needs to know that it has to send the next response. You can send headers, URI parameters, body, or query parameters, but if these parameters always contain the same values in the HTTP request, the server does not know what would be the next response. For polling scenarios like this, you implement watermarking, in which the server returns a watermark value either for the entire payload or for every item in that payload separately. For example, the watermark value can be a timestamp that refers to the entire collection, or every item could have its own timestamp. In either case, you provide a watermark expression by using the `watermark` placeholder. The expression extracts the watermark from the response and subsequently uses this watermark to send the requests to the server. You can use expressions for the body, headers, URI parameters, and query parameters values in the `watermark` placeholder. Note that in the first execution, the `watermark` placeholder value is `null`, which you might want to consider in the server or the expression where the placeholder is used. To refer to the entire payload in the watermark expression, use the `payload` placeholder. To refer to an item, use the `item` placeholder, which applies the watermarking expression each item individually. The following XML configuration example shows an HTTP **Listener** flow. In the first polling iteration, when there is no watermark, a payload is returned with a watermark value set in the `wm` property. In the second polling iteration, a watermark value is expected, so the payload is different. In this case, coming from the request’s payload: ```xml ``` The following XML configuration example shows how to extract the watermark value from the entire payload and then use the value in the body of the request. The configuration uses the HTTP **Polling Source** event source instead of the HTTP **Listener** source: ```xml ``` - The `watermarkExpression` has the `watermark` placeholder that retrieves the watermark from the property `wm` of the response. - The first polling iteration includes three executions of the flow, one execution with `{name: 'Eze'}`, another execution with `{name: 'Fabi'}`, and the last execution with `{name: 'Sofi'}`. - In the second polling iteration, which occurs five minutes later, there are two executions, one execution with `{name: 'Euge'}` and another execution with `{name: 'Juli'}`). - In the second polling iteration, which occurs five minutes later, there are two executions, one execution with `{name: 'Euge'}` and another execution with `{name: 'Juli'}`). - Afterward the third iteration, polling continues, but because the results are empty, there are no flow executions. The following XML configuration example shows how to extract the watermark value from each item and then use that value in the query parameters. The behavior depends completely on how the HTTP server uses the watermarking value: ```xml ``` ## Configuring Idempotency Expressions To avoid the concurrent execution of two flows with the same payload identification, configure idempotency for the HTTP **Polling Source** event source. This configuration ensures that payloads with the same ID are not processed concurrently. To configure idempotency for the event source, add an ID expression to retrieve the ID from the item, similar to the watermarking expression configuration. Use `payload` and `item` placeholders in the idempotency expression `idExpression`. In the following XML configuration example, the first three items execute the flow concurrently and the fourth item starts its process only after the first item finishes processing. ```xml ``` ## Configuring Response Validators Validate the responses received by configuring and using a response validator. The following XML configuration example shows a situation in which the server always returns a status code of 301, when the response validator expects a default status code between 200 and 299 and, as a result, the HTTP response always fails. This indicates that the flow does not execute, and the payload is considered valid only when the response validator defines 301 as the status code (the splitting, watermarking, and idempotency configurations are applied then): ```xml ``` ## See Also - [Configure HTTP Request Operation](https://docs.mulesoft.com/http-connector/latest/http-request-ref) - [HTTP Connector Examples](https://docs.mulesoft.com/http-connector/latest/http-connector-examples) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation) --- product: HTTP Connector version: 1.10 --- # Consume a REST Service Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure Anypoint Connector for HTTP (HTTP Connector) to consume a REST service by setting up the HTTP **Listener** source and the **Request** operation. To accomplish this example, you must: - Consume a REST API service using default HTTP configurations. - Test the HTTP request. - Edit the configuration to make secure HTTPS requests. - Test the HTTPS request. The following screenshot shows the Anypoint Studio app flow for this example: ![Consume a REST API Service flow](/mulesoft/current/en-us/http-connector/1.10/_images/http-consumerest-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message. 2. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 3. Set **Path** to `/trigger`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 5. On the **General** tab, configure the following fields: - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-startapp-example-1.png) ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-startapp-example-2.png) 7. Drag an HTTP **Request** operation to the right of HTTP **Listener**. 8. Set **URL** to `http://jsonplaceholder.typicode.com/users`. ![HTTP Request configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-consumerest-example-3.png) 9. Save your Mule app. 10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 11. Open a web browser, and go to `localhost:8081/trigger`. The **Listener** hears the request on port `8081`, and starts the app. The list of users appears in the browser. 12. Return to the **Request** configuration screen and set the **URL** field to `https://jsonplaceholder.typicode.com/users` to use the HTTPS protocol. 13. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Request** in the app. 14. Set **Port** to `443`. 15. Click **OK**. ![HTTP Request global configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-consumerest-example-4.png) 16. Save and run your Mule app. 17. Open a web browser, and go to `localhost:8081/trigger`. The **Listener** hears the request on port `8081`, and starts the app. The list of users appears in the browser. ## XML for Consuming a REST API Service Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # Consume a REST Service Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure Anypoint Connector for HTTP (HTTP Connector) to consume a REST service by setting up the HTTP **Listener** source and the **Request** operation. To accomplish this example, you must: - Consume a REST API service using default HTTP configurations. - Test the HTTP request. - Edit the configuration to make secure HTTPS requests. - Test the HTTPS request. The following screenshot shows the Anypoint Studio app flow for this example: ![Consume a REST API Service flow](/mulesoft/current/en-us/http-connector/1.11/_images/http-consumerest-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message. 2. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 3. Set **Path** to `/trigger`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 5. On the **General** tab, configure the following fields: - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-startapp-example-1.png) ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-startapp-example-2.png) 7. Drag an HTTP **Request** operation to the right of HTTP **Listener**. 8. Set **URL** to `http://jsonplaceholder.typicode.com/users`. ![HTTP Request configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-consumerest-example-3.png) 9. Save your Mule app. 10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 11. Open a web browser, and go to `localhost:8081/trigger`. The **Listener** hears the request on port `8081`, and starts the app. The list of users appears in the browser. 12. Return to the **Request** configuration screen and set the **URL** field to `https://jsonplaceholder.typicode.com/users` to use the HTTPS protocol. 13. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Request** in the app. 14. Set **Port** to `443`. 15. Click **OK**. ![HTTP Request global configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-consumerest-example-4.png) 16. Save and run your Mule app. 17. Open a web browser, and go to `localhost:8081/trigger`. The **Listener** hears the request on port `8081`, and starts the app. The list of users appears in the browser. ## XML for Consuming a REST API Service Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Consume a REST Service Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure Anypoint Connector for HTTP (HTTP Connector) to consume a REST service by setting up the HTTP **Listener** source and the **Request** operation. To accomplish this example, you must: - Consume a REST API service using default HTTP configurations. - Test the HTTP request. - Edit the configuration to make secure HTTPS requests. - Test the HTTPS request. The following screenshot shows the Anypoint Studio app flow for this example: ![Consume a REST API Service flow](/mulesoft/current/en-us/http-connector/latest/_images/http-consumerest-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message. 2. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 3. Set **Path** to `/trigger`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 5. On the **General** tab, configure the following fields: - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 6. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-startapp-example-1.png) ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-startapp-example-2.png) 7. Drag an HTTP **Request** operation to the right of HTTP **Listener**. 8. Set **URL** to `http://jsonplaceholder.typicode.com/users`. ![HTTP Request configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-consumerest-example-3.png) 9. Save your Mule app. 10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 11. Open a web browser, and go to `localhost:8081/trigger`. The **Listener** hears the request on port `8081`, and starts the app. The list of users appears in the browser. 12. Return to the **Request** configuration screen and set the **URL** field to `https://jsonplaceholder.typicode.com/users` to use the HTTPS protocol. 13. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Request** in the app. 14. Set **Port** to `443`. 15. Click **OK**. ![HTTP Request global configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-consumerest-example-4.png) 16. Save and run your Mule app. 17. Open a web browser, and go to `localhost:8081/trigger`. The **Listener** hears the request on port `8081`, and starts the app. The list of users appears in the browser. ## XML for Consuming a REST API Service Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 --- # HTTP Connector 1.10 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP (HTTP Connector) enables you to declare HTTP servers that listen to requests and trigger flows, as well as HTTP clients that can communicate with any HTTP service. Additionally, the connector enables you to both expose and consume HTTP-based APIs. For example, APIkit and RESTConnect both use HTTP Connector internally to work with APIs. HTTP Connector also supports HTTPS (TLS) connectivity, which provides easy ways to serve static resources and secure servers, and handles client authentication schemes. For information about compatibility and fixed issues, see the HTTP Connector Release Notes. ## Before You Begin To use this connector, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - How to create a Mule app using Anypoint Studio Before creating an app, you must have access to Anypoint Platform and Anypoint Studio ## HTTP Servers HTTP servers expose services for users or applications to consume. These servers receive data in the form of requests and return corresponding responses. The HTTP **Listener** source triggers flows when a request is received and responds after the flow finishes. Declare an HTTP server by defining the listener source connection. This connection defines the host and port where requests are received. The following example shows an XML example for an HTTP **Listener** source connection: ```xml ``` The connection configuration is `serverConfig`, which listens to a localhost address (IP address `127.0.0.1`) on port `8081`. After you set up a server in Anypoint Studio, you can access this server at the `http://localhost:8081` URL. To fully configure your server, specify resource paths to execute a flow so that when a request matching that path is received, Mule runtime engine (Mule) runs your flow. The following example shows the XML configuration for two HTTP **Listener** sources in different flows that execute depending on the path triggered: ```xml ``` Both listener sources use the connection configuration `serverConfig` declared in the first example. If the HTTP **Listener** source is triggered with `http://localhost:8081/greet`, the connector returns `Hello, world!`. If the source is triggered with `http://localhost:8081/exit`, the connector returns `Goodbye, world!`. The received HTTP request data is shared with the flow when executed. You can customize HTTP responses. The following example shows an XML configuration for an HTTP **Listener** source that customizes the body of the HTTP responses: ```xml #[payload ++ ' I am an HTTP server.'] ``` If the HTTP **Listener** source is triggered with `http://localhost:8081/greet?name=Ana`, the connector returns `Hello, Ana! I am an HTTP server.`. If the source is triggered with `http://localhost:8081/greet`, the connector returns `Hello, world! I am an HTTP server.`. For more information about the HTTP **Listener** source, refer to the [Configure an HTTP Listener source](https://docs.mulesoft.com/http-connector/1.10/http-listener-ref) documentation. ## HTTP Clients HTTP clients enable you to send requests to HTTP services and manage their responses. The HTTP **Request** operation executes HTTP requests and returns the corresponding answers. Although you don’t need to declare HTTP clients, declaring them enables you to reuse configurations. If you don’t declare an HTTP client, specify the entire URL each time you want to send a request to that URL. Also, if you make several requests on different API resources, declare the client to which the host connects. The following example shows an XML configuration for an HTTP **Request** operation: ```xml ``` The HTTP request configuration is `clientConfig`, and sends requests to `localhost` and port `8081`. To perform requests, each operation must include the path of the request target. The following example shows an XML configuration for two HTTP **Request** operations with different paths: ```xml ``` The service exposed is consumed by sending requests to `greet` and `exit`, and when the flow executes, it displays: ```xml Hello, world! I am an HTTP server. Goodbye, world! ``` You can customize HTTP requests to share the response data with the flow. The following example shows an HTTP **Request** operation XML configuration that customizes the request sent with query parameters and uses the received HTTP response status: ```xml #[{"name" : "HTTP client"}] ``` When the flow executes, it displays: ```xml Received a 200 response with body: {Hello, HTTP client! I am an HTTP server.} ``` For further information about the HTTP **Request** operation, refer to [Configure HTTP Request operation](https://docs.mulesoft.com/http-connector/1.10/http-request-ref) documentation. ## Next Step After you complete the prerequisites, you are ready to create an app and configure the connector using [Anypoint Studio](https://docs.mulesoft.com/http-connector/1.10/http-connector-studio). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 --- # HTTP Connector 1.10 - XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio: - If you manually code a Mule runtime engine (Mule) app in XML (either from the Anypoint Studio XML editor or from a text editor), you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. - If you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `mule` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd ``` This example shows how the namespace statements are placed in the XML: ```xml ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. When you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.connectors mule-http-connector x.x.x mule-plugin ``` Replace `` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `http`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## Next Step After completing your namespace and `pom.xml` file, you can try the [Examples](https://docs.mulesoft.com/http-connector/1.10/http-connector-examples). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 --- # HTTP Connector 1.10 Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Use Anypoint Connector for HTTP (HTTP Connector) to handle and perform HTTP requests. This class only serves as an extension definition. This connector’s configurations are divided between a server (``) and a client (``). capabilities. Release Notes: [HTTP Connector Release Notes](https://docs.mulesoft.com/release-notes/connector/connector-http) ## Configurations --- ### Listener Configuration Configuration element for a HttpListener. #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

The name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types that can be provided to this configuration.

x

Base Path

String

Base path to use for all requests that reference this config.

Listener Interceptors

Listener interceptors that will apply on request and on response events.

Reject Invalid Transfer Encoding

Boolean

If true, requests with an invalid value for Transfer-Encoding header are rejected with a 400 Bad Request message. The valid values are chunked, deflate, compress, identity and gzip. These values are defined in RFC-7230 and RFC-2616.

false

#### Connection Types ##### Listener Connection provider for a HttpListener, handles the creation of HttpServer instances. ###### Parameters
NameTypeDescriptionDefault ValueRequired

TLS Configuration

Reference to a TLS config element. This will enable HTTPS for this config.

Protocol

Enumeration, one of:

  • HTTP

  • HTTPS

Protocol to use for communication. Valid values are HTTP and HTTPS. Default value is HTTP. When using HTTPS the HTTP communication is going to be secured using TLS / SSL. If HTTPS was configured as protocol then the user needs to configure at least the keystore in the tls:context child element of this listener-config.

HTTP

Host

String

Host where the requests will be sent.

x

Port

Number

Port where the requests will be received.

x

Use Persistent Connections

Boolean

If false, each connection will be closed after the first request is completed.

true

Connection Idle Timeout

Number

The number of milliseconds that a connection can remain idle before it is closed. The value of this attribute is only used when persistent connections are enabled. The listener default connection Idle timeout is bigger than the requester connection Idle default timeout to avoid the Remotely closed exception when you send a request on an existing connection just before the timeout occurs.

40000

Read Timeout

Number

Maximum time in milliseconds that the listener must wait while receiving a message.

30000

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment will fail if the test doesn’t pass after exhausting the associated reconnection strategy

## Associated Sources - [Listener](#listener) - [Polling Source](#pollingSource) --- ### Request Configuration Configuration element for a HTTP requests. #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

The name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types that can be provided to this configuration.

x

Expiration Policy

Configures the minimum amount of time that a dynamic configuration instance can remain idle before the runtime considers it eligible for expiration. This does not mean that the platform will expire the instance at the exact moment that it becomes eligible. The runtime will actually purge the instances when it sees it fit.

Base Path

String

Base path to use for all requests that reference this config.

/

Follow Redirects

Boolean

Specifies whether to follow redirects or not. Default value is true.

true

Send Body Mode

Enumeration, one of:

  • ALWAYS

  • AUTO

  • NEVER

Defines if the request should contain a body or not. If AUTO, it will depend on the method (GET, HEAD and OPTIONS will not send a body).

AUTO

Request Streaming Mode

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Defines if the request should be sent using streaming or not. If this attribute is not present, the behavior will depend on the type of the payload (it will stream only for InputStream). If set to true, it will always stream. If set to false, it will never stream. As streaming is done the request will be sent user Transfer-Encoding: chunked.

AUTO

Enable Cookies

Boolean

If true, cookies received in HTTP responses are stored and sent in subsequent HTTP requests.

When an http:request-config element has cookies enabled, a single CookieManager is created for each instance of the request-config. If multiple http:request elements in a Mule application reference the same http:request-config, they all share the same CookieManager instance.

If you have a dynamic configuration, a new http:request-config instance is created for each parameterization. Therefore, each parameterization has its own CookieManager instance. For details, see Dynamic Configuration Lifecycle.

true

Default Headers

Default HTTP headers the message should include.

Query Parameters

Array of Query Param

Default Query parameters the request should include.

Send Correlation Id

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Whether to specify a correlation id when publishing messages. This applies both for custom correlation ids specified at the operation level and for default correlation ids taken from the current event.

AUTO

Preserve Headers Case

Boolean

By default, header keys are stored internally in lower-case. This is to improve performance of headers handling and is functionally correct as specified in the RFC. <p> In the case a server expects headers in a specific case, this flag may be set to true so the case of the header keys are preserved.

false

Response Timeout

Number

Maximum time in milliseconds that the request element blocks the execution of the flow waiting for the HTTP response. If this value isn’t set, the connector uses the defaultResponseTimeout value configured in the Mule global configuration. If no global value is configured, the default is 10000 milliseconds.

Inherited from defaultResponseTimeout (10000 ms by default)

Response Validator

Configures a default error handling of the response.

#### Connection Types ##### Request Connection provider for a HTTP request, handles the creation of HttpExtensionClient instances. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Proxy Config

Reusable configuration element for outbound connections through a proxy. A proxy element must define a host name and a port attributes, and optionally can define a username and a password.

Authentication

Authentication method to use for the HTTP request.

TLS Configuration

Reference to a TLS config element. This will enable HTTPS for this config.

Protocol

Enumeration, one of:

  • HTTP

  • HTTPS

Protocol to use for communication. Valid values are HTTP and HTTPS. Default value is HTTP. When using HTTPS the HTTP communication is going to be secured using TLS/SSL. If HTTPS was configured as protocol, then the user can customize the TLS/SSL configuration by defining the tls:context child element of this listener-config. If not tls:context is defined, then the default JVM certificates are used to establish communication.

HTTP

Host

String

Host where the requests will be sent.

Port

Number

Port where the requests will be sent. If the protocol attribute is HTTP (default) then the default value is 80, if the protocol attribute is HTTPS then the default value is 443.

Use Persistent Connections

Boolean

If false, each connection will be closed after the first request is completed.

true

Max Connections

Number

The maximum number of outbound connections that will be kept open at the same time. By default the number of connections is unlimited. Setting a value for max connections helps limit memory usage, although it may reduce throughput.

-1

Connection Idle Timeout

Number

The number of milliseconds that a connection can remain idle before it is closed. The value of this attribute is only used when persistent connections are enabled.

30000

Stream Response

Boolean

Whether or not received responses should be streamed, meaning processing will continue as soon as all headers are parsed and the body streamed as it arrives. When enabled, the response MUST be eventually read since depending on the configured buffer size it may not fit into memory and processing will stop until space is available.

false

Response Buffer Size

Number

The space in bytes for the buffer where the HTTP response will be stored.

1024

Client Socket Properties

Configures the client socket properties.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment will fail if the test doesn’t pass after exhausting the associated reconnection strategy

## Associated Operations - [Request](#request) ## Operations ### Request `` Consumes an HTTP service. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Method

String

The HTTP method for the request.

GET

Streaming Strategy

Configure if repeatable streams should be used and their behavior

Path

String

Path where the request will be sent.

URL

String

URL where to send the request.

Follow Redirects

Boolean

Specifies whether to follow redirects or not.

Send Body Mode

Enumeration, one of:

  • ALWAYS

  • AUTO

  • NEVER

Defines if the request should contain a body or not.

Request Streaming Mode

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Defines if the request should be sent using streaming or not.

Response Timeout

Number

Maximum time in milliseconds that the request element will block the execution of the flow waiting for the HTTP response.

Body

Any

The body of the response message

#[payload]

Headers

Object

HTTP headers the message should include.

URI Parameters

Object

URI parameters that should be used to create the request.

Query Parameters

Object

Query parameters the request should include.

Send Correlation Id

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Options on whether to include an outbound correlation ID or not

Correlation Id

String

Allows you to set a custom correlation ID.

Response Validator

Configures error handling of the response.

Target Variable

String

The name of a variable on which the operation’s output will be placed

Target Value

String

An expression that will be evaluated against the operation’s output and the outcome of that expression will be stored in the target variable

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors. This field is not used by this operation.

#### Output

Type

Any

Attributes Type

#### For Configurations. - [Request Configuration](#requestConfig) #### Throws - HTTP:BAD\_REQUEST - HTTP:CLIENT\_SECURITY - HTTP:CONNECTIVITY - HTTP:FORBIDDEN - HTTP:INTERNAL\_SERVER\_ERROR - HTTP:METHOD\_NOT\_ALLOWED - HTTP:NOT\_ACCEPTABLE - HTTP:NOT\_FOUND - HTTP:PARSING - HTTP:RETRY\_EXHAUSTED - HTTP:SECURITY - HTTP:SERVICE\_UNAVAILABLE - HTTP:TIMEOUT - HTTP:TOO\_MANY\_REQUESTS - HTTP:UNAUTHORIZED - HTTP:UNSUPPORTED\_MEDIA\_TYPE - HTTP:BAD\_GATEWAY - HTTP:GATEWAY\_TIMEOUT ### Basic Security Filter `` Authenticates received HTTP requests. Must be used after a listener component. #### Parameters
NameTypeDescriptionDefault ValueRequired

Realm

String

Authentication realm.

x

Security Providers

Array of String

The delegate-security-provider to use for authenticating. Use this in case you have multiple security managers defined in your configuration.

Attributes

The HttpRequestAttributes coming from an HTTP listener source to check the Authorization header.

#[attributes]

#### Throws - HTTP:BASIC\_AUTHENTICATION - MULE:SERVER\_SECURITY ### Load Static Resource `` The static resource serves static content to use with HTTP. The request path is used to look up the resource. #### Parameters
NameTypeDescriptionDefault ValueRequired

Resource Base Path

String

The resource base from where documents are served up. For example: /Users/maxthemule/resources

x

Default File

String

The default file to serve when a directory is specified. The default value is index.html.

index.html

Attributes

The HttpRequestAttributes coming from an HTTP listener source to check the required resources.

#[attributes]

Target Variable

String

The name of a variable on which the operation’s output will be placed

Target Value

String

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

#[payload]

#### Output

Type

Any

Attributes Type

Any

#### Throws - HTTP:NOT\_FOUND ## Sources ### Listener `` Represents a listener for HTTP requests. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Path

String

Relative path from the path set in the HTTP Listener configuration

x

Allowed Methods

String

Comma-separated list of allowed HTTP methods by this listener. To allow all methods do not define the attribute.

Response Streaming Mode

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Defines if the response should be sent using streaming or not. If this attribute is not present, the behavior will depend on the type of the payload (it will stream only for InputStream). If set to true, it will always stream. If set to false, it will never stream. As streaming is done the response will be sent user Transfer-Encoding: chunked.

AUTO

Primary Node Only

Boolean

Whether this source should only be executed on the primary node when running in Cluster

Streaming Strategy

Configure if repeatable streams should be used and their behavior

Redelivery Policy

Defines a policy for processing the redelivery of the same message

Reconnection Strategy

A retry strategy in case of connectivity errors

Body

Any

The body of the response message.

#[payload]

Headers

Object

HTTP headers the message should include.

Status Code

Number

HTTP status code the response should have.

Reason Phrase

String

HTTP reason phrase the response should have.

#### Output

Type

Any

Attributes Type

#### For Configurations. - [Listener Configuration](#listenerConfig) ### Polling Source `` Event source that executes a scheduled HTTP request to a given HTTP server. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Path

String

Relative path from the path set in the HTTP Request operation configuration.

Method

String

HTTP request method

GET

Response Validator

One of: * Success Status Code Validator * Failure Status Code Validator * ExpressionResponseValidator

Validation applied to the connectivity test response.

Primary Node Only

Boolean

Determines whether to execute this source only on the primary node when running Mule instances in a cluster.

On Capacity Overload

Enumeration, one of: DROP WAIT ** FAIL

Strategy that Mule applies when the flow receives more messages than it has the capacity to manage.

WAIT

Scheduling Strategy

scheduling-strategy

Configures the scheduler that triggers the polling.

x

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Redelivery Policy

Defines a policy for processing the redelivery of the same message.

Body

String

Body of the response message.

Headers

Array of pollingRequestHeader

HTTP headers the message includes.

URI Parameters

Array of pollingRequestUriParam

URI parameters used to create the request.

Query Parameters

Array of pollingRequestQueryParam

Query parameters the request includes.

Split Expression

String

The split expression to apply to the response.

Watermark Expression

String

The expression to retrieve the watermark from the (split) response.

Id Expression

String

The expression to retrieve the ID from every (split) item.

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Any

Attributes Type

### For Configurations - [Request Configuration](#requestConfig) ## Types ### TLS Reference to a TLS config element, which enables HTTPS for the configuration. > [!NOTE] Starting with Mule runtime 4.10, configure keystore and truststore paths relative to the > classpath or file system. Absolute paths throw > `KeyStore must be configured for server side SSL in configuration` unless you set > `mule.tlsStores.filesystemLookup.enable` to `true`. For more information, see > [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration).
FieldTypeDescriptionDefault ValueRequired

Enabled Protocols

String

A comma separated list of protocols enabled for this context.

Enabled Cipher Suites

String

A comma separated list of cipher suites enabled for this context. Use IANA (Internet Assigned Numbers Authority) naming convention for the cipher suites. Check the OpenSSL - IANA mapping for reference. Additionally, review TLS Configuration Examples.

Trust Store

Configures the truststore for TLS.

Key Store

Configures the keystore for the TLS protocol. The keystore you generate contains a private key and a public certificate.

Revocation Check

Configures a revocation check for TLS.

### Trust Store Configures the truststore for TLS.
FieldTypeDescriptionDefault ValueRequired

Path

String

The location (which will be resolved relative to the current classpath and file system, if possible) of the trust store.

Password

String

The password used to protect the trust store.

Type

String

The type of store used.

Algorithm

String

The algorithm used by the trust store.

Insecure

Boolean

If true, no certificate validations are performed, rendering connections vulnerable to attacks. Use at your own risk.

### Key Store Configures the keystore for the TLS protocol. The keystore you generate contains a private key and a public certificate.
FieldTypeDescriptionDefault ValueRequired

Path

String

The location (which resolves relative to the current classpath and file system, if possible) of the key store.

Type

String

The type of store used.

Alias

String

When the key store contains many private keys, this attribute indicates the alias of the key that should be used. If not defined, the first key in the file is used by default.

Key Password

String

The password used to protect the private key.

Password

String

The password used to protect the key store.

Algorithm

String

The algorithm used by the key store.

### Standard Revocation Check Configures standard revocation checks for TLS certificates.
FieldTypeDescriptionDefault ValueRequired

Only End Entities

Boolean

Only verify the last element of the certificate chain.

Prefer Crls

Boolean

Try CRL instead of OCSP first.

No Fallback

Boolean

Do not use the secondary checking method (the one not selected before).

Soft Fail

Boolean

Avoid verification failure when the revocation server can not be reached or is busy.

### Custom OCSP Responder Configures a custom OCSP responder for certification revocation checks.
FieldTypeDescriptionDefault ValueRequired

Url

String

The URL of the OCSP responder.

Cert Alias

String

Alias of the signing certificate for the OCSP response (must be in the trust store), if present.

### CRL File Specifies the location of the certification revocation list (CRL) file.
FieldTypeDescriptionDefault ValueRequired

Path

String

The path to the CRL file.

### Reconnection Configures a reconnection strategy for an operation.
FieldTypeDescriptionDefault ValueRequired

Fails Deployment

Boolean

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy

Reconnection Strategy

The reconnection strategy to use

### Reconnect Configures a standard reconnection strategy, which specifies how often to reconnect and how many reconnection attempts the connector source or operation can make.
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often in milliseconds to reconnect.

Count

Number

How many reconnection attempts to make.

blocking

Boolean

If false, the reconnection strategy runs in a separate, non-blocking thread.

true

### Reconnect Forever Configures a forever reconnection strategy by which the connector source or operation attempts to reconnect at a specified frequency for as long as the Mule app runs.
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often in milliseconds to reconnect.

blocking

Boolean

If false, the reconnection strategy runs in a separate, non-blocking thread.

true

### CORS Interceptor Wrapper
FieldTypeDescriptionDefault ValueRequired

Cors Interceptor

Interceptor which validates that requests match CORS specification and acts on responses accordingly.

x

### CORS Listener Interceptor
FieldTypeDescriptionDefault ValueRequired

Allow Credentials

Boolean

false

Origins

Array of One of:

x

### HTTP Request Attributes To get familiar on how to use message attributes, refer to the [about message attributes](https://docs.mulesoft.com/mule-runtime/latest/about-mule-message) documentation.
FieldTypeDescriptionDefault ValueRequired

Listener Path

String

Full path where the request was received.

x

Raw Request Path

String

Full path requested, encoded as received. @since 1.5.0

x

Relative Path

String

Path where the request was received, without considering the base path.

x

Masked Request Path

String

Path computed from masking the listenerPath and taking the difference. Note that this is only calculated when the null otherwise.

@since 1.4.0

x

Version

String

HTTP version of the request.

x

Scheme

String

HTTP scheme of the request.

x

Method

String

HTTP method of the request.

x

Request Uri

String

Full URI of the request.

x

Raw Request Uri

String

Full URI of the request, encoded as received. @since 1.5.0

x

Query String

String

Query string of the request.

x

Local Address

String

Local host address from the server.

x

Remote Address

String

Remote host address from the sender.

x

Client Certificate

Any

Client certificate (if 2 way TLS is enabled).

Query Params

Object

Query parameters map built from the parsed string.

x

Uri Params

Object

URI parameters extracted from the request path.

x

Request Path

String

Full path requested.

x

Headers

Object

Map of HTTP headers in the message.

x

### Repeatable In Memory Stream Configures the in-memory streaming strategy by which the request fails if the data exceeds the MAX buffer size. Always run performance tests to find the optimal buffer size for your specific use case.
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

This is the amount of memory allocated in order to consume the stream and provide random access to it. If the stream contains more data than can be fit into this buffer, then the buffer expands according to the bufferSizeIncrement attribute, with an upper limit of maxInMemorySize.

Buffer Size Increment

Number

How much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower will mean that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error will be raised when the buffer gets full.

Max Buffer Size

Number

This is the maximum amount of memory that the buffer can use. If the buffer uses more than that, a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised. A value lower or equal to zero means there’s no limit.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

The unit in which all these attributes are expressed

### Repeatable File Store Stream Configures the repeatable file-store streaming strategy by which Mule keeps a portion of the stream content in memory. If the stream content is larger than the configured buffer size, Mule backs up the buffer’s content to disk and then clears the memory.
FieldTypeDescriptionDefault ValueRequired

Max In Memory Size

Number

Defines the maximum memory that the stream can use to keep data in memory. If more than that is consumed, the content is buffered on disk.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

The unit in which maxInMemorySize is expressed

### Redelivery Policy Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.
FieldTypeDescriptionDefault ValueRequired

Max Redelivery Count

Number

The maximum number of times a message can be redelivered and processed unsuccessfully before triggering process-failed-message

Use Secure Hash

Boolean

Whether to use a secure hash algorithm to identify a redelivered message

Message Digest Algorithm

String

The secure hashing algorithm to use. If not set, the default is SHA-256.

Id Expression

String

Defines one or more expressions to use to determine when a message has been redelivered. This property may only be set if useSecureHash is false.

Object Store

ObjectStore

The object store where the redelivery counter for each message is stored.

### TCP Client Socket Properties Configures the client socket properties.
FieldTypeDescriptionDefault ValueRequired

Connection Timeout

Number

Time to wait during a connection to a remote server before failing with a timeout. If the configured requester host resolves to multiple IP addresses, the host tries to connect to every single IP address. Therefore, if every connection times out, the number of resolved IP addresses multiplies the global connection timeout.

30000

Send Tcp No Delay

Boolean

Indicates whether or not to collect the transmitted data for greater efficiency and send the data immediately.

true

Linger

Number

How long, in milliseconds, the socket takes to close, so any remaining data is transmitted correctly.

Keep Alive

Boolean

Indicates whether the open socket connections unused for a long period and with an unavailable connection can be closed.

false

Fail On Unresolved Host

Boolean

Indicates whether the socket fails during its creation if the host set on the endpoint cannot be resolved.

true

Send Buffer Size

Number

Size of the buffer, in bytes, when sending data.

Receive Buffer Size

Number

Size of the buffer, in bytes, when receiving data.

Client Timeout

Number

Time, in milliseconds, that the socket waits in a blocking operation before failing.

Reuse Address

Boolean

When trying to bind the port, indicates whether to reuse (true) or fail (false) the configured port.

true

### Expiration Policy Configures the minimum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration. This does not mean that the instance expires at the exact moment that it becomes eligible. Mule purges the instances as appropriate.
FieldTypeDescriptionDefault ValueRequired

Max Idle Time

Number

A scalar time value for the maximum amount of time a dynamic configuration instance should be allowed to be idle before it’s considered eligible for expiration

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the maxIdleTime attribute

### Default Header Default HTTP headers the message should include.
FieldTypeDescriptionDefault ValueRequired

Key

String

Key for default HTTP headers.

x

Value

String

Value for default HTTP headers.

x

### Query Param Default query parameters the request should include.
FieldTypeDescriptionDefault ValueRequired

Key

String

Key name for default query parameter.

x

Value

String

Value for default query parameter.

x

### HTTP Response Attributes To get familiar on how to use message attributes, refer to the [about message attributes](https://docs.mulesoft.com/mule-runtime/latest/about-mule-message) documentation.
FieldTypeDescriptionDefault ValueRequired

Status Code

Number

HTTP status code of the response.

x

Reason Phrase

String

HTTP reason phrase of the response.

x

Headers

Object

Map of HTTP headers in the message.

x

### Basic Authentication The basic authentication method enables an HTTP user agent to provide a username and password when making an HTTP request.
FieldTypeDescriptionDefault ValueRequired

Username

String

The username to authenticate.

x

Password

String

The password to authenticate.

x

Preemptive

Boolean

Configures if authentication should be preemptive or not. Preemptive authentication will send the authentication header in the first request, instead of waiting for a 401 response code to send it.

true

### Digest Authentication The digest authentication method enables a web server to verify user credentials via the user’s web browser.
FieldTypeDescriptionDefault ValueRequired

Username

String

The username to authenticate.

x

Password

String

The password to authenticate.

x

Preemptive

Boolean

Configures if authentication should be preemptive or not. Preemptive authentication will send the authentication header in the first request, instead of waiting for a 401 response code to send it.

true

### NTLM Authentication NT LAN Manager (NTLM) authentication replaces the authentication protocol in Microsoft LAN Manager (LANMAN), an older Microsoft product.
FieldTypeDescriptionDefault ValueRequired

Domain

String

The domain to authenticate.

Workstation

String

The workstation to authenticate.

Username

String

The username to authenticate.

x

Password

String

The password to authenticate.

x

Preemptive

Boolean

Configures if authentication should be preemptive or not. Preemptive authentication will send the authentication header in the first request, instead of waiting for a 401 response code to send it.

true

### Proxy Reusable configuration element for outbound connections through a proxy. A proxy element must define a host name and a port attributes, and optionally can define a username and a password.
FieldTypeDescriptionDefault ValueRequired

Host

String

Host where the proxy requests will be sent.

x

Port

Number

Port where the proxy requests will be sent.

x

Username

String

The username to authenticate against the proxy.

Password

String

The password to authenticate against the proxy.

Non Proxy Hosts

String

A list of comma separated hosts against which the proxy is not used

### NTLM Proxy
FieldTypeDescriptionDefault ValueRequired

Ntlm Domain

String

The domain to authenticate against the proxy.

x

Host

String

Host where the proxy requests will be sent.

x

Port

Number

Port where the proxy requests will be sent.

x

Username

String

The username to authenticate against the proxy.

Password

String

The password to authenticate against the proxy.

Non Proxy Hosts

String

A list of comma separated hosts against which the proxy is not used

### Success Status Code Validator
FieldTypeDescriptionDefault ValueRequired

Values

String

Status codes that are considered.

x

### Failure Status Code Validator
FieldTypeDescriptionDefault ValueRequired

Values

String

Status codes that are considered.

x

### Origin
FieldTypeDescriptionDefault ValueRequired

Url

String

URL of the Origins, from which the browser can load resources.

x

Access Control Max Age

Number

The amount of time, in seconds, to cache the results of a preflight request.

x

Allowed Methods

Array of Method

Indicates which HTTP methods are permitted while accessing the resources from the origin.

Allowed Headers

Array of Header

In preflight requests, indicates the HTTP headers to use during the actual request.

Expose Headers

Array of Header

Response headers exposed in the request.

### Method HTTP method name.
FieldTypeDescriptionDefault ValueRequired

Method Name

String

HTTP method name.

x

### Header HTTP header name.
FieldTypeDescriptionDefault ValueRequired

Header Name

String

HTTP header name.

x

## See Also [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # HTTP Connector 1.11 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP (HTTP Connector) enables you to declare HTTP servers that listen to requests and trigger flows, as well as HTTP clients that can communicate with any HTTP service. Additionally, the connector enables you to both expose and consume HTTP-based APIs. For example, APIkit and RESTConnect both use HTTP Connector internally to work with APIs. HTTP Connector also supports HTTPS (TLS) connectivity, which provides easy ways to serve static resources and secure servers, and handles client authentication schemes. For information about compatibility and fixed issues, see the HTTP Connector Release Notes. ## Before You Begin To use this connector, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - How to create a Mule app using Anypoint Studio Before creating an app, you must have access to Anypoint Platform and Anypoint Studio ## HTTP Servers HTTP servers expose services for users or applications to consume. These servers receive data in the form of requests and return corresponding responses. The HTTP **Listener** source triggers flows when a request is received and responds after the flow finishes. Declare an HTTP server by defining the listener source connection. This connection defines the host and port where requests are received. The following example shows an XML example for an HTTP **Listener** source connection: ```xml ``` The connection configuration is `serverConfig`, which listens to a localhost address (IP address `127.0.0.1`) on port `8081`. After you set up a server in Anypoint Studio, you can access this server at the `http://localhost:8081` URL. To fully configure your server, specify resource paths to execute a flow so that when a request matching that path is received, Mule runtime engine (Mule) runs your flow. The following example shows the XML configuration for two HTTP **Listener** sources in different flows that execute depending on the path triggered: ```xml ``` Both listener sources use the connection configuration `serverConfig` declared in the first example. If the HTTP **Listener** source is triggered with `http://localhost:8081/greet`, the connector returns `Hello, world!`. If the source is triggered with `http://localhost:8081/exit`, the connector returns `Goodbye, world!`. The received HTTP request data is shared with the flow when executed. You can customize HTTP responses. The following example shows an XML configuration for an HTTP **Listener** source that customizes the body of the HTTP responses: ```xml #[payload ++ ' I am an HTTP server.'] ``` If the HTTP **Listener** source is triggered with `http://localhost:8081/greet?name=Ana`, the connector returns `Hello, Ana! I am an HTTP server.`. If the source is triggered with `http://localhost:8081/greet`, the connector returns `Hello, world! I am an HTTP server.`. For more information about the HTTP **Listener** source, refer to the [Configure an HTTP Listener source](https://docs.mulesoft.com/http-connector/1.11/http-listener-ref) documentation. ## HTTP Clients HTTP clients enable you to send requests to HTTP services and manage their responses. The HTTP **Request** operation executes HTTP requests and returns the corresponding answers. Although you don’t need to declare HTTP clients, declaring them enables you to reuse configurations. If you don’t declare an HTTP client, specify the entire URL each time you want to send a request to that URL. Also, if you make several requests on different API resources, declare the client to which the host connects. The following example shows an XML configuration for an HTTP **Request** operation: ```xml ``` The HTTP request configuration is `clientConfig`, and sends requests to `localhost` and port `8081`. To perform requests, each operation must include the path of the request target. The following example shows an XML configuration for two HTTP **Request** operations with different paths: ```xml ``` The service exposed is consumed by sending requests to `greet` and `exit`, and when the flow executes, it displays: ```xml Hello, world! I am an HTTP server. Goodbye, world! ``` You can customize HTTP requests to share the response data with the flow. The following example shows an HTTP **Request** operation XML configuration that customizes the request sent with query parameters and uses the received HTTP response status: ```xml #[{"name" : "HTTP client"}] ``` When the flow executes, it displays: ```xml Received a 200 response with body: {Hello, HTTP client! I am an HTTP server.} ``` For further information about the HTTP **Request** operation, refer to [Configure HTTP Request operation](https://docs.mulesoft.com/http-connector/1.11/http-request-ref) documentation. ## Next Step After you complete the prerequisites, you are ready to create an app and configure the connector using [Anypoint Studio](https://docs.mulesoft.com/http-connector/1.11/http-connector-studio). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # HTTP Connector 1.11 - XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio: - If you manually code a Mule runtime engine (Mule) app in XML (either from the Anypoint Studio XML editor or from a text editor), you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. - If you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `mule` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd ``` This example shows how the namespace statements are placed in the XML: ```xml ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. When you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.connectors mule-http-connector x.x.x mule-plugin ``` Replace `` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `http`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## Next Step After completing your namespace and `pom.xml` file, you can try the [Examples](https://docs.mulesoft.com/http-connector/1.11/http-connector-examples). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # HTTP Connector 1.11 Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Use Anypoint Connector for HTTP (HTTP Connector) to handle and perform HTTP requests. This class only serves as an extension definition. This connector’s configurations are divided between a server (``) and a client (``). capabilities. Release Notes: [HTTP Connector Release Notes](https://docs.mulesoft.com/release-notes/connector/connector-http) ## Configurations --- ### Listener Configuration Configuration element for a HttpListener. #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

Name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types that can be provided to this configuration.

x

Base Path

String

Base path to use for all requests that reference this config.

Listener Interceptors

Listener interceptors that will apply on request and on response events.

Reject Invalid Transfer Encoding

Boolean

If true, request with an invalid value for Transfer-Encoding header are rejected with a 400 Bad Request message.

false

#### Connection Types ##### Listener Connection provider for a HttpListener, handles the creation of HttpServer instances. ###### Parameters
NameTypeDescriptionDefault ValueRequired

TLS Configuration

Reference to a TLS configuration element. This enables HTTPS for this configuration.

Protocol

Enumeration, one of:

  • HTTP

  • HTTPS

Protocol to use for communication. Default value is HTTP. When using HTTPS the HTTP communication is secured using TLS / SSL. If HTTPS is configured as protocol then configure at least the keystore in the tls:context child element of this listener-config.

HTTP

Host

String

Host where the requests is sent.

x

Port

Number

Port where the requests is received.

x

Use Persistent Connections

Boolean

Indicates whether to use persistent connections:

  • true

Mule uses persistent connections.

  • false

Mule closes the connection after the first request completes.

true

Connection Idle Timeout

Number

The number of milliseconds that a connection can remain idle before it’s closed. The value of this attribute is only used when persistent connections are enabled. The listener default timeout is bigger than our requester default timeout to avoid 'Remotely closed' exception when you start sending a request on an existing connection just before the timeout occurs.

40000

Read Timeout

Number

Read timeout to configure in milliseconds.

30000

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Http1 Support

Specific parameters for HTTP/1.

Http2 Support

Specific parameters for HTTP/2.

#### Associated Sources - [Listener](#listener) --- ### Request Configuration Configuration element for a HTTP requests. #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

The name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types that can be provided to this configuration.

x

Expiration Policy

Configures the minimum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration.

Base Path

String

Base path to use for all requests that reference this config.

/

Follow Redirects

Boolean

Specifies whether to follow redirects or not. Default value is true.

true

Send Body Mode

Enumeration, one of:

  • ALWAYS

  • AUTO

  • NEVER

Defines if the request contains a body or not. If AUTO, it depends on the method (GET, HEAD and OPTIONS aren’t send a body).

AUTO

Request Streaming Mode

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Defines if the request is sent using streaming or not. If this attribute isn’t present, the behavior depends on the type of the payload (it streams only for InputStream). If set to true, it always streams. If set to false, it never streams. As streaming is done the request is sent user Transfer-Encoding: chunked.

AUTO

Enable Cookies

Boolean

If true, cookies received in HTTP responses will be stored, and sent in subsequent HTTP requests.

true

Default Headers

Default HTTP headers the message includes.

Query Parameters

Default Query parameters the request includes.

Send Correlation Id

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Whether to specify a correlationId when publishing messages. This applies both for custom correlation IDs specifies at the operation level and for default correlation IDs taken from the current event.

AUTO

Preserve Headers Case

Boolean

By default, header keys are stored internally in lower-case. This is to improve performance of headers handling and is functionally correct as specified in the RFC. If a server expects headers in a specific case, this flag can be set to true so the case of the header keys are preserved.

false

Response Timeout

Number

Maximum time in milliseconds that the request element blocks the execution of the flow waiting for the HTTP response. If this value isn’t set, the connector uses the defaultResponseTimeout value configured in the Mule global configuration. If no global value is configured, the default is 10000 milliseconds.

Inherited from defaultResponseTimeout (10000 ms by default)

Response Validator

Configures a default error handling of the response.

#### Connection Types ##### Request Connection provider for a HTTP request, handles the creation of HttpExtensionClient instances. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Proxy Config

Configures a proxy for outbound connections. A proxy element must define a host name and a port attributes, and optionally can define a username and a password.

Authentication

Authentication method to use for the HTTP request.

Connectivity Test

TLS Configuration

Reference to a TLS configuration element. This enables HTTPS for this configuration.

Protocol

Enumeration, one of:

  • HTTP

  • HTTPS

Protocol to use for communication. Default value is HTTP. When using HTTPS the HTTP communication is secured using TLS / SSL. If HTTPS was configured as protocol then customize the TLS/SSL configuration by defining the tls:context child element of this listener-config. If not tls:context is defined then the default JVM certificates are used to establish communication.

HTTP

Host

String

Host where the requests is sent.

Port

Number

Port where the requests is sent. If the protocol attribute is HTTP (default) then the default value is 80, if the protocol attribute is HTTPS then the default value is 443.

Use Persistent Connections

Boolean

Indicates whether to use persistent connections:

  • true

Mule uses persistent connections.

  • false

Mule closes the connection after the first request completes.

true

Max Connections

Number

Maximum number of connections to open to the backend. HTTP requests are sent in parallel over multiple connections. Setting this value too high can impact latency and consume additional resources without increasing throughput. By default the number of connections is unlimited.

-1

Connection Idle Timeout

Number

The number of milliseconds that a connection can remain idle before it’s closed. The value of this attribute is only used when persistent connections are enabled.

30000

Stream Response

Boolean

If this value is true, Mule streams received responses, meaning processing continues as soon as all headers are parsed and the body streamed as it arrives. When enabled, the response must be eventually read since depending on the configured buffer size it may not fit into memory and processing stops until space is available.

false

Response Buffer Size

Number

Size of the buffer that stores the HTTP response, in bytes. A value of -1 (the default) means the buffer size isn’t limited and that the connector uses a system-defined default. Specify a positive number to set an explicit buffer size in bytes.

-1

Client Socket Properties

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Http1 Support

Specific parameters for HTTP/1.

Http2 Support

Specific parameters for HTTP/2.

## Supported Operations - [Request](#request) ## Associated Sources - [Polling Source](#pollingSource) ## Operations ### Request `` Consumes an HTTP service. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Method

String

The HTTP method for the request.

GET

Output Mime Type

String

The mime type of the payload that this operation outputs.

Output Encoding

String

The encoding of the payload that this operation outputs.

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Path

String

Path where the request is sent.

URL

String

URL where to send the request.

Follow Redirects

Boolean

Specifies whether to follow redirects or not.

Send Body Mode

Enumeration, one of:

  • ALWAYS

  • AUTO

  • NEVER

Defines if the request contains a body or not.

Request Streaming Mode

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Defines if the request is sent using streaming or not.

Response Timeout

Number

Maximum time that the request element blocks the execution of the flow waiting for the HTTP response.

Body

Any

The body of the response message

#[payload]

Headers

Object

HTTP headers the message includes.

URI Parameters

Object

URI parameters that can be used to create the request.

Query Parameters

Object

Query parameters the request includes.

Send Correlation Id

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Options on whether to include an outbound correlation ID or not

Correlation Id

String

Allows to set a custom correlation ID

Response Validator

Configures error handling of the response.

Target Variable

String

The name of a variable on which the operation’s output is placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Any

Attributes Type

### For Configurations - [Request Configuration](#requestConfig) #### Throws - HTTP:GATEWAY\_TIMEOUT - HTTP:UNSUPPORTED\_MEDIA\_TYPE - HTTP:CONNECTIVITY - HTTP:INTERNAL\_SERVER\_ERROR - HTTP:METHOD\_NOT\_ALLOWED - HTTP:MULTIPLE\_CHOICES - HTTP:SEE\_OTHER - HTTP:NOT\_ACCEPTABLE - HTTP:MOVED\_TEMPORARILY - HTTP:TOO\_MANY\_REQUESTS - HTTP:SERVICE\_UNAVAILABLE - HTTP:FORBIDDEN - HTTP:CLIENT\_SECURITY - HTTP:UNAUTHORIZED - HTTP:BAD\_GATEWAY - HTTP:MOVED\_PERMANENTLY - HTTP:RETRY\_EXHAUSTED - HTTP:NOT\_FOUND - HTTP:NOT\_MODIFIED - HTTP:BAD\_REQUEST - HTTP:PARSING - HTTP:TIMEOUT - HTTP:SECURITY ### Basic Security Filter `` Authenticates received HTTP requests. Use it always after a listener component. #### Parameters
NameTypeDescriptionDefault ValueRequired

Realm

String

Authentication realm.

x

Security Providers

Array of String

The delegate-security-provider to use for authenticating. Use this in case you have multiple security managers defined in your configuration.

Attributes

The HttpRequestAttributes coming from an HTTP listener source to check the Authorization header.

#[attributes]

#### Throws - HTTP:BASIC\_AUTHENTICATION - MULE:SERVER\_SECURITY ### Load Static Resource `` The static resource serves static content to use with HTTP. The request path is used to look up the resource. #### Parameters
NameTypeDescriptionDefault ValueRequired

Resource Base Path

String

The resource base from where documents are served up. For example: /Users/maxthemule/resources. Validate inputs when using expressions here to avoid overexposing files.

x

Default File

String

The default file to serve when a directory is specified. The default value is 'index.html'. Validate inputs when using expressions here to avoid overexposing files.

index.html

Attributes

The HttpRequestAttributes coming from an HTTP listener source to check the required resources.

#[attributes]

Target Variable

String

The name of a variable on which the operation’s output is placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

#### Output

Type

Any

Attributes Type

Any

#### Throws - HTTP:NOT\_FOUND ## Sources ### Listener `` Represents a listener for HTTP requests. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Path

String

Relative path from the path set in the HTTP Listener configuration

x

Allowed Methods

String

Comma-separated list of allowed HTTP methods by this listener. To allow all methods don’t define the attribute.

Response Streaming Mode

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Defines if the response is sent using streaming or not. If this attribute isn’t present, the behavior depends on the type of the payload (it streams only for InputStream). If set to true, it always streams. If set to false, it never streams. As streaming is done the response is sent user Transfer-Encoding: chunked.

AUTO

Deferred Response

Boolean

Defines if the response is sent in the same thread where the listener’s callback is notified, or scheduled to another Scheduler. This is useful when the payload to send is generated slowly.

false

Output Mime Type

String

The mime type of the payload that this operation outputs.

Output Encoding

String

The encoding of the payload that this operation outputs.

Primary Node Only

Boolean

Determines whether to execute this source on only the primary node when running Mule instances in a cluster.

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Redelivery Policy

Defines a policy for processing the redelivery of the same message.

Reconnection Strategy

Retry strategy in case of connectivity errors.

Body

Any

The body of the response message.

#[payload]

Headers

Object

HTTP headers the message includes.

Status Code

Number

HTTP status code the response has.

Reason Phrase

String

HTTP reason phrase the response has.

#### Output

Type

Any

Attributes Type

### For Configurations - [Listener Configuration](#listenerConfig) ### Polling Source `` Event source that executes a scheduled HTTP request to a given HTTP server. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Path

String

Relative path from the path set in the HTTP Requester configuration

Method

String

GET

Response Validator

Validation applied to the connectivity test response.

Output Mime Type

String

The mime type of the payload that this operation outputs.

Primary Node Only

Boolean

Determines whether to execute this source on only the primary node when running Mule instances in a cluster.

On Capacity Overload

Enumeration, one of:

  • DROP

  • WAIT

  • FAIL

Strategy that Mule applies when the flow receives more messages than it has the capacity to manage.

WAIT

Scheduling Strategy

scheduling-strategy

Configures the scheduler that triggers the polling.

x

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Redelivery Policy

Defines a policy for processing the redelivery of the same message.

Body

String

The body of the response message

Headers

HTTP headers the message includes.

URI Parameters

URI parameters that can be used to create the request.

Query Parameters

Query parameters the request includes.

Split Expression

String

The split expression to apply to the response.

Watermark Expression

String

The expression to retrieve the watermark from the (split) response.

Id Expression

String

The expression to retrieve the ID from every (split) item.

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Any

Attributes Type

### For Configurations - [Request Configuration](#requestConfig) ## Types ### TLS Configures TLS to provide secure communications for the Mule app. > [!NOTE] > > - The TLS configuration supports static configuration only and doesn’t support expressions or > dynamic configuration. For more information, see > [Dynamic Configuration Expiration](https://docs.mulesoft.com/mule-sdk/latest/static-dynamic-configs#dynamic-config-expiration). > > - Starting with Mule runtime 4.10, configure keystore and truststore paths relative to the > classpath or file system. Absolute paths throw > `KeyStore must be configured for server side SSL in configuration` unless you set > `mule.tlsStores.filesystemLookup.enable` to `true`. For more information, see > [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration).
FieldTypeDescriptionDefault ValueRequired

Enabled Protocols

String

A comma separated list of protocols enabled for this context.

Enabled Cipher Suites

String

A comma separated list of cipher suites enabled for this context.

Trust Store

Configures the TLS truststore.

Key Store

Configures the TLS keystore.

Revocation Check

### Truststore Configures the truststore for TLS.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the truststore. Mule resolves the path relative to the current classpath and file system.

Password

String

Password used to protect the truststore.

Type

String

Type of store.

Algorithm

String

Encryption algorithm that the truststore uses.

Insecure

Boolean

If true, Mule stops performing certificate validations. Setting this to true can make connections vulnerable to attacks.

### Keystore Configures the keystore for the TLS protocol. The keystore you generate contains a private key and a public certificate.
FieldTypeDescriptionDefault ValueRequired

Path

String

The path to the keystore. Mule resolves the path relative to the current classpath and file system.

Type

String

The type of store.

Alias

String

The alias of the key to use when the keystore contains multiple private keys. By default, Mule uses the first key in the file.

Key Password

String

The password used to protect the private key.

Password

String

The password used to protect the keystore.

Algorithm

String

The encryption algorithm that the keystore uses.

### Standard Revocation Check Configures standard revocation checks for TLS certificates.
FieldTypeDescriptionDefault ValueRequired

Only End Entities

Boolean

Which elements to verify in the certificate chain:

  • true

Verify only the last element in the certificate chain.

  • false

Verify all elements in the certificate chain.

Prefer Crls

Boolean

How to check certificate validity:

  • true

Check the Certification Revocation List (CRL) for certificate validity.

  • false

Use the Online Certificate Status Protocol (OCSP) to check certificate validity.

No Fallback

Boolean

Whether to use the secondary method to check certificate validity:

  • true

Use the method that wasn’t specified in the Prefer Crls field (the secondary method) to check certificate validity.

  • false

Don’t use the secondary method to check certificate validity.

Soft Fail

Boolean

What to do if the revocation server can’t be reached or is busy:

  • true

Avoid verification failure.

  • false

Allow the verification to fail.

### Custom OCSP Responder Configures a custom OCSP responder for certification revocation checks.
FieldTypeDescriptionDefault ValueRequired

Url

String

The URL of the OCSP responder.

Cert Alias

String

The alias of the signing certificate for the OCSP response. If specified, the alias must be in the truststore.

### CRL File Specifies the location of the certification revocation list (CRL) file.
FieldTypeDescriptionDefault ValueRequired

Path

String

The path to the CRL file.

### Reconnection Configures a reconnection strategy for an operation.
FieldTypeDescriptionDefault ValueRequired

Fails Deployment

Boolean

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Reconnection Strategy

The reconnection strategy to use.

### Reconnect Configures a standard reconnection strategy, which specifies how often to reconnect and how many reconnection attempts the connector source or operation can make.
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

Frequency of reconnection attempts, in milliseconds.

Count

Number

How many reconnection attempts the Mule app can make.

### Reconnect Forever Configures a forever reconnection strategy by which the connector source or operation attempts to reconnect at a specified frequency for as long as the Mule app runs.
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

Frequency of reconnection attempts, in milliseconds.

### Http1 Support Configuration
FieldTypeDescriptionDefault ValueRequired

Enable

Boolean

Enables or disables HTTP/1.

true

### Http2 Support Configuration
FieldTypeDescriptionDefault ValueRequired

Enable

Boolean

Enables or disables HTTP/2.

true

Header Table Size

Number

Allows the sender to inform the remote endpoint of the maximum size of the header compression table used to decode header blocks, in octets. The encoder can select any size equal to or less than this value by using signaling specific to the header compression format inside a header block. The initial value is 4,096 octets.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2[SETTINGS_HEADER_TABLE_SIZE (0x1)]

4096

Max Concurrent Streams

Number

Indicates the maximum number of concurrent streams that the sender allows. This limit is directional: it applies to the number of streams that the sender permits the receiver to create. Initially, there is no limit to this value. Set this value to 100 or higher to avoid reducing parallelism. Don’t treat a value of 0 for SETTINGS_MAX_CONCURRENT_STREAMS as special by endpoints. A zero value does prevent the creation of new streams; however, this can also happen for any limit that is exhausted with active streams. Servers set a zero value only for short durations. If a server doesn’t want to accept requests, closing the connection is more appropriate.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2[SETTINGS_MAX_CONCURRENT_STREAMS (0x3)]

Initial Window Size

Number

Indicates the sender’s initial window size (in octets) for stream-level flow control. The initial value is 2^16-1 (65,535) octets.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2[SETTINGS_INITIAL_WINDOW_SIZE (0x4)]

65535

Max Frame Size

Number

Indicates the size of the largest frame payload that the sender is willing to receive, in octets. The initial value is 2^14 (16,384) octets. The value advertised by an endpoint must be between this initial value and the maximum allowed frame size (2^24-1 or 16,777,215 octets), inclusive.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2[SETTINGS_MAX_FRAME_SIZE (0x5)]

16384

Max Header List Size

Number

This advisory setting informs a peer of the maximum size of header list that the sender is prepared to accept, in octets. The value is based on the uncompressed size of header fields, including the length of the name and value in octets plus an overhead of 32 octets for each header field. For any given request, a lower limit than what is advertised can be enforced. The initial value of this setting is unlimited.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2"[SETTINGS_MAX_HEADER_LIST_SIZE (0x6)]

8192

### CORS Interceptor Wrapper
FieldTypeDescriptionDefault ValueRequired

Cors Interceptor

Interceptor which validates that requests match CORS specification and acts on responses accordingly.

x

### CORS Listener Interceptor
FieldTypeDescriptionDefault ValueRequired

Allow Credentials

Boolean

false

Origins

Array of One of:

x

### HTTP Request Attributes
FieldTypeDescriptionDefault ValueRequired

Listener Path

String

Full path where the request was received. Former http.listener.path.

x

Raw Request Path

String

Full path requested, encoded as received.

@since 1.5.0

x

Relative Path

String

Path where the request was received, without considering the base path. Former http.relative.path.

x

Masked Request Path

String

Path computed from masking the listenerPath and taking the difference. This is only calculated when the listenerPath isn’t null.

@since 1.4.0

x

Version

String

HTTP version of the request. Former http.version.

x

Scheme

String

HTTP scheme of the request. Former http.scheme.

x

Method

String

HTTP method of the request. Former http.method.

x

Request Uri

String

Full URI of the request. Former http.request.uri.

x

Raw Request Uri

String

Full URI of the request, encoded as received.

@since 1.5.0

x

Query String

String

Query string of the request. Former http.query.string.

x

Local Address

String

Local host address from the server.

x

Remote Address

String

Remote host address from the sender. Former http.remote.address.

x

Client Certificate

Client certificate (if 2 way TLS is enabled). Former http.client.cert.

Query Params

Object

Query parameters map built from the parsed string. Former http.query.params.

x

Uri Params

Object

URI parameters extracted from the request path. Former http.uri.params.

x

Request Path

String

Full path requested. Former http.request.path.

x

Headers

Object

Map of HTTP headers in the message. Former properties.

x

### Certificate Data
FieldTypeDescriptionDefault ValueRequired

Basic Constraints

Number

Critical Extension OI Ds

Array of String

Encoded

Binary

Extended Key Usage

Array of String

Extensions

Issuer Alternative Names

Issuer DN

Issuer Unique ID

Array of Boolean

Issuer X500 Principal

Key Usage

Array of Boolean

Name

String

Non Critical Extension OI Ds

Array of String

Not After

Date

Not Before

Date

Public Key

Serial Number

Number

Serial Number Object

Sig Alg Name

String

Sig Alg OID

String

Sig Alg Params

Binary

Signature

Binary

Subject Alternative Names

Subject DN

Subject X500 Principal

Type

String

Version

Number

### Certificate Extension
FieldTypeDescriptionDefault ValueRequired

Criticality

Boolean

Oid

String

Value

Binary

### Alternative Name Data
FieldTypeDescriptionDefault ValueRequired

Name

String

Type

Number

### Principal Data
FieldTypeDescriptionDefault ValueRequired

Common Name

String

Name

String

### X500 Principal Data
FieldTypeDescriptionDefault ValueRequired

Name

String

### Public Key Data
FieldTypeDescriptionDefault ValueRequired

Algorithm

String

Encoded

Binary

Modulus

Number

Params

Number

Public Key

String

### Serial Number Data
FieldTypeDescriptionDefault ValueRequired

Serial Number

Number

### Repeatable In Memory Stream Configures the in-memory streaming strategy by which the request fails if the data exceeds the maximum buffer size. Always run performance tests to find the optimal buffer size for your specific use case.
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

Initial amount of memory to allocate to the data stream. If the streamed data exceeds this value, the buffer expands by Buffer Size Increment, with an upper limit of Max In Memory Size value.

Buffer Size Increment

Number

This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer doesn’t expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full.

Max Buffer Size

Number

Maximum size of the buffer. If the buffer size exceeds this value, Mule raises a STREAM_MAXIMUM_SIZE_EXCEEDED error. A value of less than or equal to 0 means no limit.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the Initial Buffer Size, Buffer Size Increment, and Buffer Unit fields.

### Repeatable File Store Stream Configures the repeatable file-store streaming strategy by which Mule keeps a portion of the stream content in memory. If the stream content is larger than the configured buffer size, Mule backs up the buffer’s content to disk and then clears the memory.
FieldTypeDescriptionDefault ValueRequired

In Memory Size

Number

Maximum amount of memory that the stream uses for data. If the amount of memory exceeds this value, Mule buffers the content to disk. To optimize performance:

  • Configure a larger buffer size to avoid the number of times Mule needs to write the buffer on disk. This increases performance, but it also limits the number of concurrent requests your application can process, because it requires additional memory.

  • Configure a smaller buffer size to decrease memory load at the expense of response time.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the In Memory Size field.

### Redelivery Policy Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.
FieldTypeDescriptionDefault ValueRequired

Max Redelivery Count

Number

Maximum number of times that a redelivered request is processed unsuccessfully before returning a REDELIVERY_EXHAUSTED error.

Use Secure Hash

Boolean

If true, Mule uses a secure hash algorithm to identify a redelivered message.

Message Digest Algorithm

String

Secure hashing algorithm to use if the Use Secure Hash field is true. If the payload of the message is a Java object, Mule ignores this value and returns the value that the payload’s hashCode() returned.

Id Expression

String

One or more expressions that determine when a message was redelivered. You can set this property only if the Use Secure Hash field is false.

Object Store

Object Store

Configures the object store that stores the redelivery counter for each message.

### HTTP Connectivity Validator
FieldTypeDescriptionDefault ValueRequired

Request Path

String

Path used in the connectivity test request URI.

x

Request Method

String

HTTP Method for the connectivity test request.

GET

Follow Redirects

Boolean

Specifies whether to follow redirects or not.

true

Response Timeout

Number

Maximum time that the request element blocks the execution of the flow waiting for the HTTP response.

10000

Response Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

Response timeout time unit.

MILLISECONDS

Request Body

String

The body in the connectivity test request. It can be an expression, but it doesn’t have any binding.

Request Headers

HTTP headers the connectivity test request includes. It allows multiple headers with the same key.

Request Query Params

Query parameters the connectivity test request includes. It allows multiple query params with the same key.

Request Uri Params

Array of URI Parameter

URI parameters the connectivity test request includes.

Response Validator

Validation applied to the connectivity test response.

### Request Header
FieldTypeDescriptionDefault ValueRequired

Key

String

Key for this type.

x

Value

String

Value for this type.

x

### Query Parameter
FieldTypeDescriptionDefault ValueRequired

Key

String

Key for this type.

x

Value

String

Value for this type.

x

### URI Parameter
FieldTypeDescriptionDefault ValueRequired

Key

String

Key for this type.

x

Value

String

Value for this type.

x

### TCP Client Socket Properties
FieldTypeDescriptionDefault ValueRequired

Connection Timeout

Number

30000

Send Tcp No Delay

Boolean

true

Linger

Number

Keep Alive

Boolean

false

Fail On Unresolved Host

Boolean

true

Send Buffer Size

Number

Receive Buffer Size

Number

Client Timeout

Number

Reuse Address

Boolean

true

### Expiration Policy Configures the minimum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration. This does not mean that the instance expires at the exact moment that it becomes eligible. Mule purges the instances as appropriate.
FieldTypeDescriptionDefault ValueRequired

Max Idle Time

Number

Maximum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration.

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

Time unit for the Max Idle Time field.

### Default Header Headers automatically added to every outbound request.
FieldTypeDescriptionDefault ValueRequired

Key

String

Key for this type.

x

Value

String

Value for this type.

x

### Query Parameter Default query parameters the request should include.
FieldTypeDescriptionDefault ValueRequired

Key

String

The key name for default query parameter.

x

Value

String

The value for default query parameter.

x

### HTTP Response Attributes Configures HTTP response attributes for the configuration.
FieldTypeDescriptionDefault ValueRequired

Status Code

Number

The HTTP status code of the response. Former http.status.

x

Reason Phrase

String

The HTTP reason phrase of the response. Former http.reason.

x

Headers

Object

The map of HTTP headers in the message. Former properties.

x

### Polling Request Header
FieldTypeDescriptionDefault ValueRequired

Key

String

The key name for the HTTP header.

x

Value

String

The value for the HTTP header. It can be an expression depending on a watermarking value that is resolved

x

### Polling Request Uri Param
FieldTypeDescriptionDefault ValueRequired

Key

String

The key name for the HTTP URI parameter.

x

Value

String

The value for the HTTP URI parameter. It can be an expression depending on a watermarking value that is resolved

x

### Polling Request Query Param
FieldTypeDescriptionDefault ValueRequired

Key

String

The key name for the HTTP query parameter.

x

Value

String

The value for the HTTP query parameter. It can be an expression depending on a watermarking value that is resolved

x

### Basic Authentication The basic authentication method enables an HTTP user agent to provide a username and password when making an HTTP request.
FieldTypeDescriptionDefault ValueRequired

Username

String

The username to authenticate.

x

Password

String

The password to authenticate.

x

Preemptive

Boolean

Configures if authentication is preemptive or not. Preemptive authentication sends the authentication header in the first request, instead of waiting for a 401 response code to send it.

true

### Digest Authentication The digest authentication method enables a web server to verify user credentials via the user’s web browser.
FieldTypeDescriptionDefault ValueRequired

Username

String

The username to authenticate.

x

Password

String

The password to authenticate.

x

Preemptive

Boolean

Configures if authentication is preemptive or not. Preemptive authentication sends the authentication header in the first request, instead of waiting for a 401 response code to send it.

true

### NTLM Authentication NT LAN Manager (NTLM) authentication replaces the authentication protocol in Microsoft LAN Manager (LANMAN), an older Microsoft product.
FieldTypeDescriptionDefault ValueRequired

Domain

String

The domain to authenticate.

Workstation

String

The workstation to authenticate.

Username

String

The username to authenticate.

x

Password

String

The password to authenticate.

x

Preemptive

Boolean

Configures if authentication is preemptive or not. Preemptive authentication sends the authentication header in the first request, instead of waiting for a 401 response code to send it.

true

### Proxy Reusable configuration element for outbound connections through a proxy. A proxy element must define a host name and a port attributes, and optionally can define a username and a password.
FieldTypeDescriptionDefault ValueRequired

Host

String

Host where the proxy requests is sent.

x

Port

Number

Port where the proxy requests is sent.

x

Username

String

The username to authenticate against the proxy.

Password

String

The password to authenticate against the proxy.

Non Proxy Hosts

String

A list of comma separated hosts against which the proxy isn’t used

### NTLM Proxy
FieldTypeDescriptionDefault ValueRequired

NTLM Domain

String

The domain to authenticate against the proxy.

x

Host

String

Host where the proxy requests is sent.

x

Port

Number

Port where the proxy requests is sent.

x

Username

String

The username to authenticate against the proxy.

Password

String

The password to authenticate against the proxy.

Non Proxy Hosts

String

A list of comma separated hosts against which the proxy isn’t used

### Success Status Code Validator
FieldTypeDescriptionDefault ValueRequired

Values

String

Status codes that are considered.

x

### Failure Status Code Validator
FieldTypeDescriptionDefault ValueRequired

Values

String

Status codes that are considered.

x

### Expression Response Validator
FieldTypeDescriptionDefault ValueRequired

Expression

String

DataWeave expression.

x

### Origin
FieldTypeDescriptionDefault ValueRequired

Url

String

x

Access Control Max Age

Number

x

Allowed Methods

Array of Method

Allowed Headers

Array of Header

Expose Headers

Array of Header

### Method HTTP method name.
FieldTypeDescriptionDefault ValueRequired

Method Name

String

HTTP method name.

x

### Header HTTP header name.
FieldTypeDescriptionDefault ValueRequired

Header Name

String

HTTP header name.

x

## See Also [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # HTTP Connector 1.12 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP (HTTP Connector) enables you to declare HTTP servers that listen to requests and trigger flows, as well as HTTP clients that can communicate with any HTTP service. Additionally, the connector enables you to both expose and consume HTTP-based APIs. For example, APIkit and RESTConnect both use HTTP Connector internally to work with APIs. HTTP Connector also supports HTTPS (TLS) connectivity, which provides easy ways to serve static resources and secure servers, and handles client authentication schemes. For information about compatibility and fixed issues, see the HTTP Connector Release Notes. ## Before You Begin To use this connector, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - How to create a Mule app using Anypoint Studio Before creating an app, you must have access to Anypoint Platform and Anypoint Studio ## HTTP Servers HTTP servers expose services for users or applications to consume. These servers receive data in the form of requests and return corresponding responses. The HTTP **Listener** source triggers flows when a request is received and responds after the flow finishes. Declare an HTTP server by defining the listener source connection. This connection defines the host and port where requests are received. The following example shows an XML example for an HTTP **Listener** source connection: ```xml ``` The connection configuration is `serverConfig`, which listens to a localhost address (IP address `127.0.0.1`) on port `8081`. After you set up a server in Anypoint Studio, you can access this server at the `http://localhost:8081` URL. To fully configure your server, specify resource paths to execute a flow so that when a request matching that path is received, Mule runtime engine (Mule) runs your flow. The following example shows the XML configuration for two HTTP **Listener** sources in different flows that execute depending on the path triggered: ```xml ``` Both listener sources use the connection configuration `serverConfig` declared in the first example. If the HTTP **Listener** source is triggered with `http://localhost:8081/greet`, the connector returns `Hello, world!`. If the source is triggered with `http://localhost:8081/exit`, the connector returns `Goodbye, world!`. The received HTTP request data is shared with the flow when executed. You can customize HTTP responses. The following example shows an XML configuration for an HTTP **Listener** source that customizes the body of the HTTP responses: ```xml #[payload ++ ' I am an HTTP server.'] ``` If the HTTP **Listener** source is triggered with `http://localhost:8081/greet?name=Ana`, the connector returns `Hello, Ana! I am an HTTP server.`. If the source is triggered with `http://localhost:8081/greet`, the connector returns `Hello, world! I am an HTTP server.`. For more information about the HTTP **Listener** source, refer to the [Configure an HTTP Listener source](https://docs.mulesoft.com/http-connector/latest/http-listener-ref) documentation. ## HTTP Clients HTTP clients enable you to send requests to HTTP services and manage their responses. The HTTP **Request** operation executes HTTP requests and returns the corresponding answers. Although you don’t need to declare HTTP clients, declaring them enables you to reuse configurations. If you don’t declare an HTTP client, specify the entire URL each time you want to send a request to that URL. Also, if you make several requests on different API resources, declare the client to which the host connects. The following example shows an XML configuration for an HTTP **Request** operation: ```xml ``` The HTTP request configuration is `clientConfig`, and sends requests to `localhost` and port `8081`. To perform requests, each operation must include the path of the request target. The following example shows an XML configuration for two HTTP **Request** operations with different paths: ```xml ``` The service exposed is consumed by sending requests to `greet` and `exit`, and when the flow executes, it displays: ```xml Hello, world! I am an HTTP server. Goodbye, world! ``` You can customize HTTP requests to share the response data with the flow. The following example shows an HTTP **Request** operation XML configuration that customizes the request sent with query parameters and uses the received HTTP response status: ```xml #[{"name" : "HTTP client"}] ``` When the flow executes, it displays: ```xml Received a 200 response with body: {Hello, HTTP client! I am an HTTP server.} ``` For further information about the HTTP **Request** operation, refer to [Configure HTTP Request operation](https://docs.mulesoft.com/http-connector/latest/http-request-ref) documentation. ## Next Step After you complete the prerequisites, you are ready to create an app and configure the connector using [Anypoint Studio](https://docs.mulesoft.com/http-connector/latest/http-connector-studio). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # HTTP Connector 1.12 - XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio: - If you manually code a Mule runtime engine (Mule) app in XML (either from the Anypoint Studio XML editor or from a text editor), you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. - If you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `mule` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd ``` This example shows how the namespace statements are placed in the XML: ```xml ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. When you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.connectors mule-http-connector x.x.x mule-plugin ``` Replace `` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `http`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## Next Step After completing your namespace and `pom.xml` file, you can try the [Examples](https://docs.mulesoft.com/http-connector/latest/http-connector-examples). ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # HTTP Connector 1.12 Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Use Anypoint Connector for HTTP (HTTP Connector) to handle and perform HTTP requests. This class only serves as an extension definition. This connector’s configurations are divided between a server (``) and a client (``). capabilities. Release Notes: [HTTP Connector Release Notes](https://docs.mulesoft.com/release-notes/connector/connector-http) ## Configurations --- ### Listener Configuration Configuration element for a HttpListener. #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

Name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types that can be provided to this configuration.

x

Base Path

String

Base path to use for all requests that reference this config.

Listener Interceptors

Listener interceptors that will apply on request and on response events.

Reject Invalid Transfer Encoding

Boolean

If true, request with an invalid value for Transfer-Encoding header are rejected with a 400 Bad Request message.

false

#### Connection Types ##### Listener Connection provider for a HttpListener, handles the creation of HttpServer instances. ###### Parameters
NameTypeDescriptionDefault ValueRequired

TLS Configuration

Reference to a TLS configuration element. This enables HTTPS for this configuration.

Protocol

Enumeration, one of:

  • HTTP

  • HTTPS

Protocol to use for communication. Default value is HTTP. When using HTTPS the HTTP communication is secured using TLS / SSL. If HTTPS is configured as protocol then configure at least the keystore in the tls:context child element of this listener-config.

HTTP

Host

String

Host where the requests is sent.

x

Port

Number

Port where the requests is received.

x

Use Persistent Connections

Boolean

Indicates whether to use persistent connections:

  • true

Mule uses persistent connections.

  • false

Mule closes the connection after the first request completes.

true

Connection Idle Timeout

Number

The number of milliseconds that a connection can remain idle before it’s closed. The value of this attribute is only used when persistent connections are enabled. The listener default timeout is bigger than our requester default timeout to avoid 'Remotely closed' exception when you start sending a request on an existing connection just before the timeout occurs.

40000

Read Timeout

Number

Read timeout to configure in milliseconds.

30000

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Http1 Support

Specific parameters for HTTP/1.

Http2 Support

Specific parameters for HTTP/2.

#### Associated Sources - [Listener](#listener) --- ### Request Configuration Configuration element for a HTTP requests. #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

The name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types that can be provided to this configuration.

x

Expiration Policy

Configures the minimum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration.

Base Path

String

Base path to use for all requests that reference this config.

/

Follow Redirects

Boolean

Specifies whether to follow redirects or not. Default value is true.

true

Send Body Mode

Enumeration, one of:

  • ALWAYS

  • AUTO

  • NEVER

Defines if the request contains a body or not. If AUTO, it depends on the method (GET, HEAD and OPTIONS aren’t send a body).

AUTO

Request Streaming Mode

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Defines if the request is sent using streaming or not. If this attribute isn’t present, the behavior depends on the type of the payload (it streams only for InputStream). If set to true, it always streams. If set to false, it never streams. As streaming is done the request is sent user Transfer-Encoding: chunked.

AUTO

Enable Cookies

Boolean

If true, cookies received in HTTP responses will be stored, and sent in subsequent HTTP requests.

true

Default Headers

Default HTTP headers the message includes.

Query Parameters

Default Query parameters the request includes.

Send Correlation Id

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Whether to specify a correlationId when publishing messages. This applies both for custom correlation IDs specifies at the operation level and for default correlation IDs taken from the current event.

AUTO

Preserve Headers Case

Boolean

By default, header keys are stored internally in lower-case. This is to improve performance of headers handling and is functionally correct as specified in the RFC. If a server expects headers in a specific case, this flag can be set to true so the case of the header keys are preserved.

false

Response Timeout

Number

Maximum time in milliseconds that the request element blocks the execution of the flow waiting for the HTTP response. If this value isn’t set, the connector uses the defaultResponseTimeout value configured in the Mule global configuration. If no global value is configured, the default is 10000 milliseconds.

Inherited from defaultResponseTimeout (10000 ms by default)

Response Validator

Configures a default error handling of the response.

#### Connection Types ##### Request Connection provider for a HTTP request, handles the creation of HttpExtensionClient instances. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Proxy Config

Configures a proxy for outbound connections. A proxy element must define a host name and a port attributes, and optionally can define a username and a password.

Authentication

Authentication method to use for the HTTP request.

Connectivity Test

TLS Configuration

Reference to a TLS configuration element. This enables HTTPS for this configuration.

Protocol

Enumeration, one of:

  • HTTP

  • HTTPS

Protocol to use for communication. Default value is HTTP. When using HTTPS the HTTP communication is secured using TLS / SSL. If HTTPS was configured as protocol then customize the TLS/SSL configuration by defining the tls:context child element of this listener-config. If not tls:context is defined then the default JVM certificates are used to establish communication.

HTTP

Host

String

Host where the request is sent. The autogenerated Host header includes the resolved port, including the protocol’s default port. See Configure the Host Header.

Port

Number

Port where the requests is sent. If the protocol attribute is HTTP (default) then the default value is 80, if the protocol attribute is HTTPS then the default value is 443.

Use Persistent Connections

Boolean

Indicates whether to use persistent connections:

  • true

Mule uses persistent connections.

  • false

Mule closes the connection after the first request completes.

true

Max Connections

Number

Maximum number of connections to open to the backend. This value defines a connection pool shared by all HTTP Request operations that use the same configuration, and requests are sent in parallel over multiple connections. Set this value explicitly to a number that comfortably exceeds the maximum concurrent requests expected through the configuration, for example, from a parallel-foreach scope, and account for long Response Timeout values, which keep connections in use longer. Avoid the default of unlimited (-1) without careful consideration, because an unbounded pool can lead to resource exhaustion, and a value that is too high can impact latency without increasing throughput.

-1

Connection Idle Timeout

Number

The number of milliseconds that a connection can remain idle before it’s closed. The value of this attribute is only used when persistent connections are enabled. Set this value explicitly so that it outlasts the time between consecutive requests under peak load. When a load balancer or other intermediate device sits between the Mule app and the backend, set this value lower than that device’s idle timeout to avoid Grizzly IdleTimeoutFilter errors. For example, CloudHub 2.0 ingress closes idle connections after 15 seconds. To avoid Remotely closed errors, set this value to less than 15000, for example, 10000 to 12000.

30000

Stream Response

Boolean

If this value is true, Mule streams received responses, meaning processing continues as soon as all headers are parsed and the body streamed as it arrives. When enabled, the response must be eventually read since depending on the configured buffer size it may not fit into memory and processing stops until space is available.

false

Response Buffer Size

Number

Size of the buffer that stores the HTTP response, in bytes. A value of -1 (the default) means the buffer size isn’t limited and that the connector uses a system-defined default. Specify a positive number to set an explicit buffer size in bytes.

-1

Client Socket Properties

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Http1 Support

Specific parameters for HTTP/1.

Http2 Support

Specific parameters for HTTP/2.

## Supported Operations - [Request](#request) ## Associated Sources - [Polling Source](#pollingSource) ## Operations ### Request `` Consumes an HTTP service. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Method

String

The HTTP method for the request.

GET

Output Mime Type

String

The mime type of the payload that this operation outputs.

Output Encoding

String

The encoding of the payload that this operation outputs.

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Path

String

Path where the request is sent.

URL

String

URL where to send the request. Configuring a complete URL can influence Host header generation. See Configure the Host Header.

Follow Redirects

Boolean

Specifies whether to follow redirects or not.

Send Body Mode

Enumeration, one of:

  • ALWAYS

  • AUTO

  • NEVER

Defines if the request contains a body or not.

Request Streaming Mode

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Defines if the request is sent using streaming or not.

Response Timeout

Number

Maximum time that the request element blocks the execution of the flow waiting for the HTTP response.

Body

Any

The body of the response message

#[payload]

Headers

Object

HTTP headers the message includes.

URI Parameters

Object

URI parameters that can be used to create the request.

Query Parameters

Object

Query parameters the request includes.

Send Correlation Id

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Options on whether to include an outbound correlation ID or not

Correlation Id

String

Allows to set a custom correlation ID

Response Validator

Configures error handling of the response.

Target Variable

String

The name of a variable on which the operation’s output is placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Any

Attributes Type

### For Configurations - [Request Configuration](#requestConfig) #### Throws - HTTP:GATEWAY\_TIMEOUT - HTTP:UNSUPPORTED\_MEDIA\_TYPE - HTTP:CONNECTIVITY - HTTP:INTERNAL\_SERVER\_ERROR - HTTP:METHOD\_NOT\_ALLOWED - HTTP:MULTIPLE\_CHOICES - HTTP:SEE\_OTHER - HTTP:NOT\_ACCEPTABLE - HTTP:MOVED\_TEMPORARILY - HTTP:TOO\_MANY\_REQUESTS - HTTP:SERVICE\_UNAVAILABLE - HTTP:FORBIDDEN - HTTP:CLIENT\_SECURITY - HTTP:UNAUTHORIZED - HTTP:BAD\_GATEWAY - HTTP:MOVED\_PERMANENTLY - HTTP:RETRY\_EXHAUSTED - HTTP:NOT\_FOUND - HTTP:NOT\_MODIFIED - HTTP:BAD\_REQUEST - HTTP:PARSING - HTTP:TIMEOUT - HTTP:SECURITY ### Basic Security Filter `` Authenticates received HTTP requests. Use it always after a listener component. #### Parameters
NameTypeDescriptionDefault ValueRequired

Realm

String

Authentication realm.

x

Security Providers

Array of String

The delegate-security-provider to use for authenticating. Use this in case you have multiple security managers defined in your configuration.

Attributes

The HttpRequestAttributes coming from an HTTP listener source to check the Authorization header.

#[attributes]

#### Throws - HTTP:BASIC\_AUTHENTICATION - MULE:SERVER\_SECURITY ### Load Static Resource `` The static resource serves static content to use with HTTP. The request path is used to look up the resource. #### Parameters
NameTypeDescriptionDefault ValueRequired

Resource Base Path

String

The resource base from where documents are served up. For example: /Users/maxthemule/resources. Validate inputs when using expressions here to avoid overexposing files.

x

Default File

String

The default file to serve when a directory is specified. The default value is 'index.html'. Validate inputs when using expressions here to avoid overexposing files.

index.html

Attributes

The HttpRequestAttributes coming from an HTTP listener source to check the required resources.

#[attributes]

Target Variable

String

The name of a variable on which the operation’s output is placed

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable

#[payload]

#### Output

Type

Any

Attributes Type

Any

#### Throws - HTTP:NOT\_FOUND ## Sources ### Listener `` Represents a listener for HTTP requests. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Path

String

Relative path from the path set in the HTTP Listener configuration

x

Allowed Methods

String

Comma-separated list of allowed HTTP methods by this listener. To allow all methods don’t define the attribute.

Response Streaming Mode

Enumeration, one of:

  • AUTO

  • ALWAYS

  • NEVER

Defines if the response is sent using streaming or not. If this attribute isn’t present, the behavior depends on the type of the payload (it streams only for InputStream). If set to true, it always streams. If set to false, it never streams. As streaming is done the response is sent user Transfer-Encoding: chunked.

AUTO

Deferred Response

Boolean

Defines if the response is sent in the same thread where the listener’s callback is notified, or scheduled to another Scheduler. This is useful when the payload to send is generated slowly.

false

Output Mime Type

String

The mime type of the payload that this operation outputs.

Output Encoding

String

The encoding of the payload that this operation outputs.

Primary Node Only

Boolean

Determines whether to execute this source on only the primary node when running Mule instances in a cluster.

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Redelivery Policy

Defines a policy for processing the redelivery of the same message.

Reconnection Strategy

Retry strategy in case of connectivity errors.

Body

Any

The body of the response message.

#[payload]

Headers

Object

HTTP headers the message includes.

Status Code

Number

HTTP status code the response has.

Reason Phrase

String

HTTP reason phrase the response has.

#### Output

Type

Any

Attributes Type

### For Configurations - [Listener Configuration](#listenerConfig) ### Polling Source `` Event source that executes a scheduled HTTP request to a given HTTP server. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

Name of the configuration to use.

x

Path

String

Relative path from the path set in the HTTP Requester configuration

Method

String

GET

Response Validator

Validation applied to the connectivity test response.

Output Mime Type

String

The mime type of the payload that this operation outputs.

Primary Node Only

Boolean

Determines whether to execute this source on only the primary node when running Mule instances in a cluster.

On Capacity Overload

Enumeration, one of:

  • DROP

  • WAIT

  • FAIL

Strategy that Mule applies when the flow receives more messages than it has the capacity to manage.

WAIT

Scheduling Strategy

scheduling-strategy

Configures the scheduler that triggers the polling.

x

Streaming Strategy

Configures how Mule processes streams. Repeatable streams are the default behavior.

Redelivery Policy

Defines a policy for processing the redelivery of the same message.

Body

String

The body of the response message

Headers

HTTP headers the message includes.

URI Parameters

URI parameters that can be used to create the request.

Query Parameters

Query parameters the request includes.

Split Expression

String

The split expression to apply to the response.

Watermark Expression

String

The expression to retrieve the watermark from the (split) response.

Id Expression

String

The expression to retrieve the ID from every (split) item.

Reconnection Strategy

Retry strategy in case of connectivity errors.

#### Output

Type

Any

Attributes Type

### For Configurations - [Request Configuration](#requestConfig) ## Types ### TLS Configures TLS to provide secure communications for the Mule app. > [!NOTE] > > - The TLS configuration supports static configuration only and doesn’t support expressions or > dynamic configuration. For more information, see > [Dynamic Configuration Expiration](https://docs.mulesoft.com/mule-sdk/latest/static-dynamic-configs#dynamic-config-expiration). > > - Starting with Mule runtime 4.10, configure keystore and truststore paths relative to the > classpath or file system. Absolute paths throw > `KeyStore must be configured for server side SSL in configuration` unless you set > `mule.tlsStores.filesystemLookup.enable` to `true`. For more information, see > [Configure TLS with Keystores and Truststores](https://docs.mulesoft.com/mule-runtime/latest/tls-configuration).
FieldTypeDescriptionDefault ValueRequired

Enabled Protocols

String

A comma separated list of protocols enabled for this context.

Enabled Cipher Suites

String

A comma separated list of cipher suites enabled for this context.

Trust Store

Configures the TLS truststore.

Key Store

Configures the TLS keystore.

Revocation Check

### Truststore Configures the truststore for TLS.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the truststore. Mule resolves the path relative to the current classpath and file system.

Password

String

Password used to protect the truststore.

Type

String

Type of store.

Algorithm

String

Encryption algorithm that the truststore uses.

Insecure

Boolean

If true, Mule stops performing certificate validations. Setting this to true can make connections vulnerable to attacks.

### Keystore Configures the keystore for the TLS protocol. The keystore you generate contains a private key and a public certificate.
FieldTypeDescriptionDefault ValueRequired

Path

String

The path to the keystore. Mule resolves the path relative to the current classpath and file system.

Type

String

The type of store.

Alias

String

The alias of the key to use when the keystore contains multiple private keys. By default, Mule uses the first key in the file.

Key Password

String

The password used to protect the private key.

Password

String

The password used to protect the keystore.

Algorithm

String

The encryption algorithm that the keystore uses.

### Standard Revocation Check Configures standard revocation checks for TLS certificates.
FieldTypeDescriptionDefault ValueRequired

Only End Entities

Boolean

Which elements to verify in the certificate chain:

  • true

Verify only the last element in the certificate chain.

  • false

Verify all elements in the certificate chain.

Prefer Crls

Boolean

How to check certificate validity:

  • true

Check the Certification Revocation List (CRL) for certificate validity.

  • false

Use the Online Certificate Status Protocol (OCSP) to check certificate validity.

No Fallback

Boolean

Whether to use the secondary method to check certificate validity:

  • true

Use the method that wasn’t specified in the Prefer Crls field (the secondary method) to check certificate validity.

  • false

Don’t use the secondary method to check certificate validity.

Soft Fail

Boolean

What to do if the revocation server can’t be reached or is busy:

  • true

Avoid verification failure.

  • false

Allow the verification to fail.

### Custom OCSP Responder Configures a custom OCSP responder for certification revocation checks.
FieldTypeDescriptionDefault ValueRequired

Url

String

The URL of the OCSP responder.

Cert Alias

String

The alias of the signing certificate for the OCSP response. If specified, the alias must be in the truststore.

### CRL File Specifies the location of the certification revocation list (CRL) file.
FieldTypeDescriptionDefault ValueRequired

Path

String

The path to the CRL file.

### Reconnection Configures a reconnection strategy for an operation.
FieldTypeDescriptionDefault ValueRequired

Fails Deployment

Boolean

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Reconnection Strategy

The reconnection strategy to use.

### Reconnect Configures a standard reconnection strategy, which specifies how often to reconnect and how many reconnection attempts the connector source or operation can make.
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

Frequency of reconnection attempts, in milliseconds.

Count

Number

How many reconnection attempts the Mule app can make.

### Reconnect Forever Configures a forever reconnection strategy by which the connector source or operation attempts to reconnect at a specified frequency for as long as the Mule app runs.
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

Frequency of reconnection attempts, in milliseconds.

### Http1 Support Configuration
FieldTypeDescriptionDefault ValueRequired

Enable

Boolean

Enables or disables HTTP/1.

true

### Http2 Support Configuration
FieldTypeDescriptionDefault ValueRequired

Enable

Boolean

Enables or disables HTTP/2.

true

Header Table Size

Number

Allows the sender to inform the remote endpoint of the maximum size of the header compression table used to decode header blocks, in octets. The encoder can select any size equal to or less than this value by using signaling specific to the header compression format inside a header block. The initial value is 4,096 octets.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2[SETTINGS_HEADER_TABLE_SIZE (0x1)]

4096

Max Concurrent Streams

Number

Indicates the maximum number of concurrent streams that the sender allows. This limit is directional: it applies to the number of streams that the sender permits the receiver to create. Initially, there is no limit to this value. Set this value to 100 or higher to avoid reducing parallelism. Don’t treat a value of 0 for SETTINGS_MAX_CONCURRENT_STREAMS as special by endpoints. A zero value does prevent the creation of new streams; however, this can also happen for any limit that is exhausted with active streams. Servers set a zero value only for short durations. If a server doesn’t want to accept requests, closing the connection is more appropriate.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2[SETTINGS_MAX_CONCURRENT_STREAMS (0x3)]

Initial Window Size

Number

Indicates the sender’s initial window size (in octets) for stream-level flow control. The initial value is 2^16-1 (65,535) octets.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2[SETTINGS_INITIAL_WINDOW_SIZE (0x4)]

65535

Max Frame Size

Number

Indicates the size of the largest frame payload that the sender is willing to receive, in octets. The initial value is 2^14 (16,384) octets. The value advertised by an endpoint must be between this initial value and the maximum allowed frame size (2^24-1 or 16,777,215 octets), inclusive.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2[SETTINGS_MAX_FRAME_SIZE (0x5)]

16384

Max Header List Size

Number

This advisory setting informs a peer of the maximum size of header list that the sender is prepared to accept, in octets. The value is based on the uncompressed size of header fields, including the length of the name and value in octets plus an overhead of 32 octets for each header field. For any given request, a lower limit than what is advertised can be enforced. The initial value of this setting is unlimited.

See https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2"[SETTINGS_MAX_HEADER_LIST_SIZE (0x6)]

8192

### CORS Interceptor Wrapper
FieldTypeDescriptionDefault ValueRequired

Cors Interceptor

Interceptor which validates that requests match CORS specification and acts on responses accordingly.

x

### CORS Listener Interceptor
FieldTypeDescriptionDefault ValueRequired

Allow Credentials

Boolean

false

Origins

Array of One of:

x

### HTTP Request Attributes
FieldTypeDescriptionDefault ValueRequired

Listener Path

String

Full path where the request was received. Former http.listener.path.

x

Raw Request Path

String

Full path requested, encoded as received.

@since 1.5.0

x

Relative Path

String

Path where the request was received, without considering the base path. Former http.relative.path.

x

Masked Request Path

String

Path computed from masking the listenerPath and taking the difference. This is only calculated when the listenerPath isn’t null.

@since 1.4.0

x

Version

String

HTTP version of the request. Former http.version.

x

Scheme

String

HTTP scheme of the request. Former http.scheme.

x

Method

String

HTTP method of the request. Former http.method.

x

Request Uri

String

Full URI of the request. Former http.request.uri.

x

Raw Request Uri

String

Full URI of the request, encoded as received.

@since 1.5.0

x

Query String

String

Query string of the request. Former http.query.string.

x

Local Address

String

Local host address from the server.

x

Remote Address

String

Remote host address from the sender. Former http.remote.address.

x

Client Certificate

Client certificate (if 2 way TLS is enabled). Former http.client.cert.

Query Params

Object

Query parameters map built from the parsed string. Former http.query.params.

x

Uri Params

Object

URI parameters extracted from the request path. Former http.uri.params.

x

Request Path

String

Full path requested. Former http.request.path.

x

Headers

Object

Map of HTTP headers in the message. Former properties.

x

### Certificate Data
FieldTypeDescriptionDefault ValueRequired

Basic Constraints

Number

Critical Extension OI Ds

Array of String

Encoded

Binary

Extended Key Usage

Array of String

Extensions

Issuer Alternative Names

Issuer DN

Issuer Unique ID

Array of Boolean

Issuer X500 Principal

Key Usage

Array of Boolean

Name

String

Non Critical Extension OI Ds

Array of String

Not After

Date

Not Before

Date

Public Key

Serial Number

Number

Serial Number Object

Sig Alg Name

String

Sig Alg OID

String

Sig Alg Params

Binary

Signature

Binary

Subject Alternative Names

Subject DN

Subject X500 Principal

Type

String

Version

Number

### Certificate Extension
FieldTypeDescriptionDefault ValueRequired

Criticality

Boolean

Oid

String

Value

Binary

### Alternative Name Data
FieldTypeDescriptionDefault ValueRequired

Name

String

Type

Number

### Principal Data
FieldTypeDescriptionDefault ValueRequired

Common Name

String

Name

String

### X500 Principal Data
FieldTypeDescriptionDefault ValueRequired

Name

String

### Public Key Data
FieldTypeDescriptionDefault ValueRequired

Algorithm

String

Encoded

Binary

Modulus

Number

Params

Number

Public Key

String

### Serial Number Data
FieldTypeDescriptionDefault ValueRequired

Serial Number

Number

### Repeatable In Memory Stream Configures the in-memory streaming strategy by which the request fails if the data exceeds the maximum buffer size. Always run performance tests to find the optimal buffer size for your specific use case.
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

Initial amount of memory to allocate to the data stream. If the streamed data exceeds this value, the buffer expands by Buffer Size Increment, with an upper limit of Max In Memory Size value.

Buffer Size Increment

Number

This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer doesn’t expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full.

Max Buffer Size

Number

Maximum size of the buffer. If the buffer size exceeds this value, Mule raises a STREAM_MAXIMUM_SIZE_EXCEEDED error. A value of less than or equal to 0 means no limit.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the Initial Buffer Size, Buffer Size Increment, and Buffer Unit fields.

### Repeatable File Store Stream Configures the repeatable file-store streaming strategy by which Mule keeps a portion of the stream content in memory. If the stream content is larger than the configured buffer size, Mule backs up the buffer’s content to disk and then clears the memory.
FieldTypeDescriptionDefault ValueRequired

In Memory Size

Number

Maximum amount of memory that the stream uses for data. If the amount of memory exceeds this value, Mule buffers the content to disk. To optimize performance:

  • Configure a larger buffer size to avoid the number of times Mule needs to write the buffer on disk. This increases performance, but it also limits the number of concurrent requests your application can process, because it requires additional memory.

  • Configure a smaller buffer size to decrease memory load at the expense of response time.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

Unit for the In Memory Size field.

### Redelivery Policy Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.
FieldTypeDescriptionDefault ValueRequired

Max Redelivery Count

Number

Maximum number of times that a redelivered request is processed unsuccessfully before returning a REDELIVERY_EXHAUSTED error.

Use Secure Hash

Boolean

If true, Mule uses a secure hash algorithm to identify a redelivered message.

Message Digest Algorithm

String

Secure hashing algorithm to use if the Use Secure Hash field is true. If the payload of the message is a Java object, Mule ignores this value and returns the value that the payload’s hashCode() returned.

Id Expression

String

One or more expressions that determine when a message was redelivered. You can set this property only if the Use Secure Hash field is false.

Object Store

Object Store

Configures the object store that stores the redelivery counter for each message.

### HTTP Connectivity Validator
FieldTypeDescriptionDefault ValueRequired

Request Path

String

Path used in the connectivity test request URI.

x

Request Method

String

HTTP Method for the connectivity test request.

GET

Follow Redirects

Boolean

Specifies whether to follow redirects or not.

true

Response Timeout

Number

Maximum time that the request element blocks the execution of the flow waiting for the HTTP response.

10000

Response Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

Response timeout time unit.

MILLISECONDS

Request Body

String

The body in the connectivity test request. It can be an expression, but it doesn’t have any binding.

Request Headers

HTTP headers the connectivity test request includes. It allows multiple headers with the same key.

Request Query Params

Query parameters the connectivity test request includes. It allows multiple query params with the same key.

Request Uri Params

Array of URI Parameter

URI parameters the connectivity test request includes.

Response Validator

Validation applied to the connectivity test response.

### Request Header
FieldTypeDescriptionDefault ValueRequired

Key

String

Key for this type.

x

Value

String

Value for this type.

x

### Query Parameter
FieldTypeDescriptionDefault ValueRequired

Key

String

Key for this type.

x

Value

String

Value for this type.

x

### URI Parameter
FieldTypeDescriptionDefault ValueRequired

Key

String

Key for this type.

x

Value

String

Value for this type.

x

### TCP Client Socket Properties
FieldTypeDescriptionDefault ValueRequired

Connection Timeout

Number

30000

Send Tcp No Delay

Boolean

true

Linger

Number

Keep Alive

Boolean

false

Fail On Unresolved Host

Boolean

true

Send Buffer Size

Number

Receive Buffer Size

Number

Client Timeout

Number

Reuse Address

Boolean

true

### Expiration Policy Configures the minimum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration. This does not mean that the instance expires at the exact moment that it becomes eligible. Mule purges the instances as appropriate.
FieldTypeDescriptionDefault ValueRequired

Max Idle Time

Number

Maximum amount of time that a dynamic configuration instance can remain idle before Mule considers it eligible for expiration.

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

Time unit for the Max Idle Time field.

### Default Header Headers automatically added to every outbound request.
FieldTypeDescriptionDefault ValueRequired

Key

String

Key for this type.

x

Value

String

Value for this type.

x

### Query Parameter Default query parameters the request should include.
FieldTypeDescriptionDefault ValueRequired

Key

String

The key name for default query parameter.

x

Value

String

The value for default query parameter.

x

### HTTP Response Attributes Configures HTTP response attributes for the configuration.
FieldTypeDescriptionDefault ValueRequired

Status Code

Number

The HTTP status code of the response. Former http.status.

x

Reason Phrase

String

The HTTP reason phrase of the response. Former http.reason.

x

Headers

Object

The map of HTTP headers in the message. Former properties.

x

### Polling Request Header
FieldTypeDescriptionDefault ValueRequired

Key

String

The key name for the HTTP header.

x

Value

String

The value for the HTTP header. It can be an expression depending on a watermarking value that is resolved

x

### Polling Request Uri Param
FieldTypeDescriptionDefault ValueRequired

Key

String

The key name for the HTTP URI parameter.

x

Value

String

The value for the HTTP URI parameter. It can be an expression depending on a watermarking value that is resolved

x

### Polling Request Query Param
FieldTypeDescriptionDefault ValueRequired

Key

String

The key name for the HTTP query parameter.

x

Value

String

The value for the HTTP query parameter. It can be an expression depending on a watermarking value that is resolved

x

### Basic Authentication The basic authentication method enables an HTTP user agent to provide a username and password when making an HTTP request.
FieldTypeDescriptionDefault ValueRequired

Username

String

The username to authenticate.

x

Password

String

The password to authenticate.

x

Preemptive

Boolean

Configures if authentication is preemptive or not. Preemptive authentication sends the authentication header in the first request, instead of waiting for a 401 response code to send it.

true

### Digest Authentication The digest authentication method enables a web server to verify user credentials via the user’s web browser.
FieldTypeDescriptionDefault ValueRequired

Username

String

The username to authenticate.

x

Password

String

The password to authenticate.

x

Preemptive

Boolean

Configures if authentication is preemptive or not. Preemptive authentication sends the authentication header in the first request, instead of waiting for a 401 response code to send it.

true

### NTLM Authentication NT LAN Manager (NTLM) authentication replaces the authentication protocol in Microsoft LAN Manager (LANMAN), an older Microsoft product.
FieldTypeDescriptionDefault ValueRequired

Domain

String

The domain to authenticate.

Workstation

String

The workstation to authenticate.

Username

String

The username to authenticate.

x

Password

String

The password to authenticate.

x

Preemptive

Boolean

Configures if authentication is preemptive or not. Preemptive authentication sends the authentication header in the first request, instead of waiting for a 401 response code to send it.

true

### Proxy Reusable configuration element for outbound connections through a proxy. A proxy element must define a host name and a port attributes, and optionally can define a username and a password.
FieldTypeDescriptionDefault ValueRequired

Host

String

Host where the proxy requests is sent.

x

Port

Number

Port where the proxy requests is sent.

x

Username

String

The username to authenticate against the proxy.

Password

String

The password to authenticate against the proxy.

Non Proxy Hosts

String

A list of comma separated hosts against which the proxy isn’t used

### NTLM Proxy
FieldTypeDescriptionDefault ValueRequired

NTLM Domain

String

The domain to authenticate against the proxy.

x

Host

String

Host where the proxy requests is sent.

x

Port

Number

Port where the proxy requests is sent.

x

Username

String

The username to authenticate against the proxy.

Password

String

The password to authenticate against the proxy.

Non Proxy Hosts

String

A list of comma separated hosts against which the proxy isn’t used

### Success Status Code Validator
FieldTypeDescriptionDefault ValueRequired

Values

String

Status codes that are considered.

x

### Failure Status Code Validator
FieldTypeDescriptionDefault ValueRequired

Values

String

Status codes that are considered.

x

### Expression Response Validator
FieldTypeDescriptionDefault ValueRequired

Expression

String

DataWeave expression.

x

### Origin
FieldTypeDescriptionDefault ValueRequired

Url

String

x

Access Control Max Age

Number

x

Allowed Methods

Array of Method

Allowed Headers

Array of Header

Expose Headers

Array of Header

### Method HTTP method name.
FieldTypeDescriptionDefault ValueRequired

Method Name

String

HTTP method name.

x

### Header HTTP header name.
FieldTypeDescriptionDefault ValueRequired

Header Name

String

HTTP header name.

x

## See Also [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 keywords: anypoint, connectors, transports --- # HTTP Connector Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To fully benefit from using Anypoint Connector for HTTP (HTTP Connector), see the following examples of configuring the connector in Anypoint Studio. ## HTTP Connector Studio Examples The following examples illustrate how to configure the connector in Anypoint Studio: - [Start an App from a Browser](https://docs.mulesoft.com/http-connector/1.10/http-start-app-brows-task) Configure the HTTP **Listener** operation to start an app from a browser. - [Consume a REST Service](https://docs.mulesoft.com/http-connector/1.10/http-consume-web-svc-task) Configure both the HTTP **Listener** and HTTP **Request** operations to consume a REST service. - [Load a Static Resource](https://docs.mulesoft.com/http-connector/1.10/http-load-static-res-task) Configure both the HTTP **Listener** and HTTP **Load static resource** operations to load a static resource. - [Route HTTP Requests to Different Paths](https://docs.mulesoft.com/http-connector/1.10/http-conn-route-diff-paths-task) Configure the HTTP **Listener** operation and **Logger** component to route HTTP requests to different paths. - [Route Requests Based on HTTP Method](https://docs.mulesoft.com/http-connector/1.10/http-route-methods-based-task) Configure the HTTP **Listener** source to route requests based on HTTP methods. - [Post a Form](https://docs.mulesoft.com/http-connector/1.10/http-post-form-task) Configure the HTTP **Listener** source, **Choice Router** and **Set Payload** components to post a form by sending HTTP requests. - [Set HTTP Error Status and Reason](https://docs.mulesoft.com/http-connector/1.10/http-error-status-reason-phrase-task) Configure the HTTP **Listener** source and the **Validation Module**, **Set Payload**, and **Error Handler** components to set the error status code and reason phrase for a user login validation request. - [Configure HTTP Basic Security Filter](https://docs.mulesoft.com/http-connector/1.10/http-connector-basic-security) Configure the **Basic Security Filter** operation to enforce basic authentication. --- product: HTTP Connector version: 1.11 keywords: anypoint, connectors, transports --- # HTTP Connector Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To fully benefit from using Anypoint Connector for HTTP (HTTP Connector), see the following examples of configuring the connector in Anypoint Studio. ## HTTP Connector Studio Examples The following examples illustrate how to configure the connector in Anypoint Studio: - [Start an App from a Browser](https://docs.mulesoft.com/http-connector/1.11/http-start-app-brows-task) Configure the HTTP **Listener** operation to start an app from a browser. - [Consume a REST Service](https://docs.mulesoft.com/http-connector/1.11/http-consume-web-svc-task) Configure both the HTTP **Listener** and HTTP **Request** operations to consume a REST service. - [Load a Static Resource](https://docs.mulesoft.com/http-connector/1.11/http-load-static-res-task) Configure both the HTTP **Listener** and HTTP **Load static resource** operations to load a static resource. - [Route HTTP Requests to Different Paths](https://docs.mulesoft.com/http-connector/1.11/http-conn-route-diff-paths-task) Configure the HTTP **Listener** operation and **Logger** component to route HTTP requests to different paths. - [Route Requests Based on HTTP Method](https://docs.mulesoft.com/http-connector/1.11/http-route-methods-based-task) Configure the HTTP **Listener** source to route requests based on HTTP methods. - [Post a Form](https://docs.mulesoft.com/http-connector/1.11/http-post-form-task) Configure the HTTP **Listener** source, **Choice Router** and **Set Payload** components to post a form by sending HTTP requests. - [Set HTTP Error Status and Reason](https://docs.mulesoft.com/http-connector/1.11/http-error-status-reason-phrase-task) Configure the HTTP **Listener** source and the **Validation Module**, **Set Payload**, and **Error Handler** components to set the error status code and reason phrase for a user login validation request. - [Configure HTTP Basic Security Filter](https://docs.mulesoft.com/http-connector/1.11/http-connector-basic-security) Configure the **Basic Security Filter** operation to enforce basic authentication. --- product: HTTP Connector version: 1.12 is-latest-version: true keywords: anypoint, connectors, transports --- # HTTP Connector Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To fully benefit from using Anypoint Connector for HTTP (HTTP Connector), see the following examples of configuring the connector in Anypoint Studio. ## HTTP Connector Studio Examples The following examples illustrate how to configure the connector in Anypoint Studio: - [Start an App from a Browser](https://docs.mulesoft.com/http-connector/latest/http-start-app-brows-task) Configure the HTTP **Listener** operation to start an app from a browser. - [Consume a REST Service](https://docs.mulesoft.com/http-connector/latest/http-consume-web-svc-task) Configure both the HTTP **Listener** and HTTP **Request** operations to consume a REST service. - [Load a Static Resource](https://docs.mulesoft.com/http-connector/latest/http-load-static-res-task) Configure both the HTTP **Listener** and HTTP **Load static resource** operations to load a static resource. - [Route HTTP Requests to Different Paths](https://docs.mulesoft.com/http-connector/latest/http-conn-route-diff-paths-task) Configure the HTTP **Listener** operation and **Logger** component to route HTTP requests to different paths. - [Route Requests Based on HTTP Method](https://docs.mulesoft.com/http-connector/latest/http-route-methods-based-task) Configure the HTTP **Listener** source to route requests based on HTTP methods. - [Post a Form](https://docs.mulesoft.com/http-connector/latest/http-post-form-task) Configure the HTTP **Listener** source, **Choice Router** and **Set Payload** components to post a form by sending HTTP requests. - [Set HTTP Error Status and Reason](https://docs.mulesoft.com/http-connector/latest/http-error-status-reason-phrase-task) Configure the HTTP **Listener** source and the **Validation Module**, **Set Payload**, and **Error Handler** components to set the error status code and reason phrase for a user login validation request. - [Configure HTTP Basic Security Filter](https://docs.mulesoft.com/http-connector/latest/http-connector-basic-security) Configure the **Basic Security Filter** operation to enforce basic authentication. --- product: HTTP Connector version: 1.10 keywords: connectors, http, https, configuration --- # HTTP Connector XML Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP (HTTP Connector) listens for events or performs operations based on the HTTP or HTTPS protocol. When using the HTTPS protocol, the connector requires a TLS context child element configuration. The following examples show HTTP Connector source and operations configuration in XML. ## HTTP Listener XML Configuration Example The `http:listener-config` parent element organizes connection elements, such as the listen `port` and `tls:context`, inside a child `http:listener-connection` element. The following example shows the XML configuration: ```xml ``` The following example shows the XML configuration of an `http:listener` source in a flow: ```xml ``` To access HTTP listener attributes, use DataWeave syntax as shown in the following table:
HTTP objectMule runtime engine 4.x

Method

#[attributes.method]

Path

#[attributes.listenerPath]

Relative Path

#[attributes.relativePath]

Request URI

#[attributes.requestUri]

Query String

#[attributes.queryString]

Query Parameters

#[attributes.queryParams]

URI Parameters

#[attributes.uriParams]

Version

#[attributes.version]

Scheme

#[attributes.scheme]

Headers

#[attributes.headers]

Remote Address

#[attributes.remoteAddress]

Client Certificate

#[attributes.clientCertificate]

## HTTP Request XML Configuration Example The `http:request-config` parent element organizes connection elements of the request inside a child `http:request-connection` element. The following example shows the XML configuration: ```xml
``` The following example shows the XML configuration of an `http:request` operation in a flow: ```xml ``` The HTTP request returns `HttpResponseAttributes`. To access HTTP request attributes, use DataWeave syntax as shown in the following table:
HTTP objectMule runtime engine 4.x

Status Code

#[attributes.statusCode]

Reason Phrase

#[attributes.reasonPhrase]

Headers

#[attributes.headers]

## HTTP Load Static Resource XML Configuration Example The following example shows the XML configuration of an `http:load-static-resource` operation in a flow: ```xml ``` ## HTTP Basic Security Filter XML Configuration Example The following example shows the XML configuration of an `http:basic-security-filter` operation in a flow: ```xml ``` ## HTTP Request, Response, and Error Response Body XML Example Defining the body of an HTTP request, response, and error response is optional. When you do not explicitly define the body element, the request or response returns the default payload. The following example shows the XML configuration of an `http:request` operation that defines a custom `body`, a key/value `query-parameter`, an X-Custom `header`, and a `uri-params` with the `uriParamsMap` variable that populates the URI parameter `uriParam`: ```xml #['Custom body'] #[{'X-Custom' : 'custom'}] #[uriParamsMap] #[{'key’' : 'value’'}] ``` The following example shows the XML configuration of an `http:listener` source that lacks a defined `body` element. The returned value is the default payload. The payload defines an `http:response` to a successful execution that consists of a `200` `statusCode` and `Ok` as the `reasonPhrase`, with `headers` `Name` as `content`, and `Something` as `someValue`: ```xml #[{"Name" : "content", "Something" : someValue}] ``` The following example shows the XML configuration of an `http:listener` source that defines a response to an execution failure that returns a `502` `statusCode` and `Failure` as the `reasonPhrase`, with `headers` `Error` as `FIRE` and `body` as `Oops, something is wrong`: ```xml #[‘Oops, something is wrong’] #[{"Error" : "FIRE"}] ``` ## See Also - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation) --- product: HTTP Connector version: 1.11 keywords: connectors, http, https, configuration --- # HTTP Connector XML Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP (HTTP Connector) listens for events or performs operations based on the HTTP or HTTPS protocol. When using the HTTPS protocol, the connector requires a TLS context child element configuration. The following examples show HTTP Connector source and operations configuration in XML. ## HTTP Listener XML Configuration Example The `http:listener-config` parent element organizes connection elements, such as the listen `port` and `tls:context`, inside a child `http:listener-connection` element. The following example shows the XML configuration: ```xml ``` The following example shows the XML configuration of an `http:listener` source in a flow: ```xml ``` To access HTTP listener attributes, use DataWeave syntax as shown in the following table:
HTTP objectMule runtime engine 4.x

Method

#[attributes.method]

Path

#[attributes.listenerPath]

Relative Path

#[attributes.relativePath]

Request URI

#[attributes.requestUri]

Query String

#[attributes.queryString]

Query Parameters

#[attributes.queryParams]

URI Parameters

#[attributes.uriParams]

Version

#[attributes.version]

Scheme

#[attributes.scheme]

Headers

#[attributes.headers]

Remote Address

#[attributes.remoteAddress]

Client Certificate

#[attributes.clientCertificate]

## HTTP Request XML Configuration Example The `http:request-config` parent element organizes connection elements of the request inside a child `http:request-connection` element. The following example shows the XML configuration: ```xml
``` The following example shows the XML configuration of an `http:request` operation in a flow: ```xml ``` The HTTP request returns `HttpResponseAttributes`. To access HTTP request attributes, use DataWeave syntax as shown in the following table:
HTTP objectMule runtime engine 4.x

Status Code

#[attributes.statusCode]

Reason Phrase

#[attributes.reasonPhrase]

Headers

#[attributes.headers]

## HTTP Load Static Resource XML Configuration Example The following example shows the XML configuration of an `http:load-static-resource` operation in a flow: ```xml ``` ## HTTP Basic Security Filter XML Configuration Example The following example shows the XML configuration of an `http:basic-security-filter` operation in a flow: ```xml ``` ## HTTP Request, Response, and Error Response Body XML Example Defining the body of an HTTP request, response, and error response is optional. When you do not explicitly define the body element, the request or response returns the default payload. The following example shows the XML configuration of an `http:request` operation that defines a custom `body`, a key/value `query-parameter`, an X-Custom `header`, and a `uri-params` with the `uriParamsMap` variable that populates the URI parameter `uriParam`: ```xml #['Custom body'] #[{'X-Custom' : 'custom'}] #[uriParamsMap] #[{'key’' : 'value’'}] ``` The following example shows the XML configuration of an `http:listener` source that lacks a defined `body` element. The returned value is the default payload. The payload defines an `http:response` to a successful execution that consists of a `200` `statusCode` and `Ok` as the `reasonPhrase`, with `headers` `Name` as `content`, and `Something` as `someValue`: ```xml #[{"Name" : "content", "Something" : someValue}] ``` The following example shows the XML configuration of an `http:listener` source that defines a response to an execution failure that returns a `502` `statusCode` and `Failure` as the `reasonPhrase`, with `headers` `Error` as `FIRE` and `body` as `Oops, something is wrong`: ```xml #[‘Oops, something is wrong’] #[{"Error" : "FIRE"}] ``` ## See Also - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation) --- product: HTTP Connector version: 1.12 is-latest-version: true keywords: connectors, http, https, configuration --- # HTTP Connector XML Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for HTTP (HTTP Connector) listens for events or performs operations based on the HTTP or HTTPS protocol. When using the HTTPS protocol, the connector requires a TLS context child element configuration. The following examples show HTTP Connector source and operations configuration in XML. ## HTTP Listener XML Configuration Example The `http:listener-config` parent element organizes connection elements, such as the listen `port` and `tls:context`, inside a child `http:listener-connection` element. The following example shows the XML configuration: ```xml ``` The following example shows the XML configuration of an `http:listener` source in a flow: ```xml ``` To access HTTP listener attributes, use DataWeave syntax as shown in the following table:
HTTP objectMule runtime engine 4.x

Method

#[attributes.method]

Path

#[attributes.listenerPath]

Relative Path

#[attributes.relativePath]

Request URI

#[attributes.requestUri]

Query String

#[attributes.queryString]

Query Parameters

#[attributes.queryParams]

URI Parameters

#[attributes.uriParams]

Version

#[attributes.version]

Scheme

#[attributes.scheme]

Headers

#[attributes.headers]

Remote Address

#[attributes.remoteAddress]

Client Certificate

#[attributes.clientCertificate]

## HTTP Request XML Configuration Example The `http:request-config` parent element organizes connection elements of the request inside a child `http:request-connection` element. The following example shows the XML configuration: ```xml
``` The following example shows the XML configuration of an `http:request` operation in a flow: ```xml ``` The HTTP request returns `HttpResponseAttributes`. To access HTTP request attributes, use DataWeave syntax as shown in the following table:
HTTP objectMule runtime engine 4.x

Status Code

#[attributes.statusCode]

Reason Phrase

#[attributes.reasonPhrase]

Headers

#[attributes.headers]

## HTTP Load Static Resource XML Configuration Example The following example shows the XML configuration of an `http:load-static-resource` operation in a flow: ```xml ``` ## HTTP Basic Security Filter XML Configuration Example The following example shows the XML configuration of an `http:basic-security-filter` operation in a flow: ```xml ``` ## HTTP Request, Response, and Error Response Body XML Example Defining the body of an HTTP request, response, and error response is optional. When you do not explicitly define the body element, the request or response returns the default payload. The following example shows the XML configuration of an `http:request` operation that defines a custom `body`, a key/value `query-parameter`, an X-Custom `header`, and a `uri-params` with the `uriParamsMap` variable that populates the URI parameter `uriParam`: ```xml #['Custom body'] #[{'X-Custom' : 'custom'}] #[uriParamsMap] #[{'key’' : 'value’'}] ``` The following example shows the XML configuration of an `http:listener` source that lacks a defined `body` element. The returned value is the default payload. The payload defines an `http:response` to a successful execution that consists of a `200` `statusCode` and `Ok` as the `reasonPhrase`, with `headers` `Name` as `content`, and `Something` as `someValue`: ```xml #[{"Name" : "content", "Something" : someValue}] ``` The following example shows the XML configuration of an `http:listener` source that defines a response to an execution failure that returns a `502` `statusCode` and `Failure` as the `reasonPhrase`, with `headers` `Error` as `FIRE` and `body` as `Oops, something is wrong`: ```xml #[‘Oops, something is wrong’] #[{"Error" : "FIRE"}] ``` ## See Also - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation) --- product: HTTP Connector version: 1.10 --- # HTTP Error Status Code and Reason Phrase Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure Anypoint Connector for HTTP (HTTP Connector) **Listener** source, so you can set the error status code and reason phrase for a user login validation request. To view the status code and explanation of an HTTP request, use a browser extension, or the [curl](https://curl.se/) command line utility. The example expects to receive requests in the address of `http://localhost:8081/login/`, these requests must contain a query parameter named `user`. Depending on the value of this parameter, one of two things may occur: - When the parameter equals to `user=mule`: - The validation operation evaluates the parameter as true. - A set payload transformer sets the message payload to a success message. - The HTTP Connector sets variables in **Status Code** and **Reason** as `200 Log in Successful!`. - When the parameter equals to `user=anythingElse`: - The validation operation assertion on the parameter fails. - The flow calls an error handler. - The HTTP Connector sets the variables in **Status Code** and **Reason** as `404 Requested user does not exist` Note that in either case, the request response doesn’t display as the response body, so it won’t display if you make your request through a browser window. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![HTTP Error Status Code and Reason Phrase Flow](/mulesoft/current/en-us/http-connector/1.10/_images/http-error-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. 2. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 3. Set **Path** to `/login`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Listener** in the app. 5. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` 6. Click **OK**. ![HTTP Listener Configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-error-studio-1.png) 7. On the **Response** section of the **Responses** tab of the HTTP Listener, set the **Status Code** to `200` and the **Reason phrase** to `Login Successful`. 8. On the **Error Response** section, set the **Status Code** to `#[vars.errorStatusCode]` and the **Reason phrase** to `#[vars.errorReasonPhrase]`. ![HTTP Error Status Code and Reason](/mulesoft/current/en-us/http-connector/1.10/_images/http-error-studio-2.png) 9. Drag a **Validation: Is True** operation after the HTTP **Listener** source. 10. On the **General** section of the **General** tab, select **Expression** from the dropdown menu, and to validate the `user` query parameter, add the following code in the expression field box: ```text #[attributes.queryParams.user == 'mule'] ``` ![Validate Module Configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-error-studio-3.png) 11. Drag a **Set Payload** transformer after the **Validation: Is True** operation, and set the **Value** field to `Log in Successful!` ![Set Payload Configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-error-studio-4.png) Figure 1. Set Payload Configuration 11. On the **Error Handling** section of your flow, add an **On Error Propagate** component. 12. On the **On Error Propagate** component, add two **Set Variable** transformers: - On the first variable, set **Display Name** to `Set Status Code`, **Name** to `errorStatusCode` and **Value** to `404`. - On the second variable, set **Display Name** to `Set Reason Phrase`, set **Name** to `errorReasonPhrase` and **Value** to `Requested user does not exist`. ![Error Handling Configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-error-studio-5.png) 13. Save your Mule app. 14. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 15. In cURL test the URL `[http://localhost:8081/login?user=mule](http://localhost:8081/login?user=mule)` If the user is valid, the result returns `200 Log in Successful!` otherwise, returns `404 Requested user does not exist`. ## XML for HTTP Error Status Code and Reason Phrase Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # HTTP Error Status Code and Reason Phrase Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure Anypoint Connector for HTTP (HTTP Connector) **Listener** source, so you can set the error status code and reason phrase for a user login validation request. To view the status code and explanation of an HTTP request, use a browser extension, or the [curl](https://curl.se/) command line utility. The example expects to receive requests in the address of `http://localhost:8081/login/`, these requests must contain a query parameter named `user`. Depending on the value of this parameter, one of two things may occur: - When the parameter equals to `user=mule`: - The validation operation evaluates the parameter as true. - A set payload transformer sets the message payload to a success message. - The HTTP Connector sets variables in **Status Code** and **Reason** as `200 Log in Successful!`. - When the parameter equals to `user=anythingElse`: - The validation operation assertion on the parameter fails. - The flow calls an error handler. - The HTTP Connector sets the variables in **Status Code** and **Reason** as `404 Requested user does not exist` Note that in either case, the request response doesn’t display as the response body, so it won’t display if you make your request through a browser window. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![HTTP Error Status Code and Reason Phrase Flow](/mulesoft/current/en-us/http-connector/1.11/_images/http-error-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. 2. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 3. Set **Path** to `/login`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Listener** in the app. 5. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` 6. Click **OK**. ![HTTP Listener Configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-error-studio-1.png) 7. On the **Response** section of the **Responses** tab of the HTTP Listener, set the **Status Code** to `200` and the **Reason phrase** to `Login Successful`. 8. On the **Error Response** section, set the **Status Code** to `#[vars.errorStatusCode]` and the **Reason phrase** to `#[vars.errorReasonPhrase]`. ![HTTP Error Status Code and Reason](/mulesoft/current/en-us/http-connector/1.11/_images/http-error-studio-2.png) 9. Drag a **Validation: Is True** operation after the HTTP **Listener** source. 10. On the **General** section of the **General** tab, select **Expression** from the dropdown menu, and to validate the `user` query parameter, add the following code in the expression field box: ```text #[attributes.queryParams.user == 'mule'] ``` ![Validate Module Configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-error-studio-3.png) 11. Drag a **Set Payload** transformer after the **Validation: Is True** operation, and set the **Value** field to `Log in Successful!` ![Set Payload Configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-error-studio-4.png) Figure 1. Set Payload Configuration 11. On the **Error Handling** section of your flow, add an **On Error Propagate** component. 12. On the **On Error Propagate** component, add two **Set Variable** transformers: - On the first variable, set **Display Name** to `Set Status Code`, **Name** to `errorStatusCode` and **Value** to `404`. - On the second variable, set **Display Name** to `Set Reason Phrase`, set **Name** to `errorReasonPhrase` and **Value** to `Requested user does not exist`. ![Error Handling Configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-error-studio-5.png) 13. Save your Mule app. 14. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 15. In cURL test the URL `[http://localhost:8081/login?user=mule](http://localhost:8081/login?user=mule)` If the user is valid, the result returns `200 Log in Successful!` otherwise, returns `404 Requested user does not exist`. ## XML for HTTP Error Status Code and Reason Phrase Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # HTTP Error Status Code and Reason Phrase Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure Anypoint Connector for HTTP (HTTP Connector) **Listener** source, so you can set the error status code and reason phrase for a user login validation request. To view the status code and explanation of an HTTP request, use a browser extension, or the [curl](https://curl.se/) command line utility. The example expects to receive requests in the address of `http://localhost:8081/login/`, these requests must contain a query parameter named `user`. Depending on the value of this parameter, one of two things may occur: - When the parameter equals to `user=mule`: - The validation operation evaluates the parameter as true. - A set payload transformer sets the message payload to a success message. - The HTTP Connector sets variables in **Status Code** and **Reason** as `200 Log in Successful!`. - When the parameter equals to `user=anythingElse`: - The validation operation assertion on the parameter fails. - The flow calls an error handler. - The HTTP Connector sets the variables in **Status Code** and **Reason** as `404 Requested user does not exist` Note that in either case, the request response doesn’t display as the response body, so it won’t display if you make your request through a browser window. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![HTTP Error Status Code and Reason Phrase Flow](/mulesoft/current/en-us/http-connector/latest/_images/http-error-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. 2. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 3. Set **Path** to `/login`. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP **Listener** in the app. 5. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` 6. Click **OK**. ![HTTP Listener Configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-error-studio-1.png) 7. On the **Response** section of the **Responses** tab of the HTTP Listener, set the **Status Code** to `200` and the **Reason phrase** to `Login Successful`. 8. On the **Error Response** section, set the **Status Code** to `#[vars.errorStatusCode]` and the **Reason phrase** to `#[vars.errorReasonPhrase]`. ![HTTP Error Status Code and Reason](/mulesoft/current/en-us/http-connector/latest/_images/http-error-studio-2.png) 9. Drag a **Validation: Is True** operation after the HTTP **Listener** source. 10. On the **General** section of the **General** tab, select **Expression** from the dropdown menu, and to validate the `user` query parameter, add the following code in the expression field box: ```text #[attributes.queryParams.user == 'mule'] ``` ![Validate Module Configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-error-studio-3.png) 11. Drag a **Set Payload** transformer after the **Validation: Is True** operation, and set the **Value** field to `Log in Successful!` ![Set Payload Configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-error-studio-4.png) Figure 1. Set Payload Configuration 11. On the **Error Handling** section of your flow, add an **On Error Propagate** component. 12. On the **On Error Propagate** component, add two **Set Variable** transformers: - On the first variable, set **Display Name** to `Set Status Code`, **Name** to `errorStatusCode` and **Value** to `404`. - On the second variable, set **Display Name** to `Set Reason Phrase`, set **Name** to `errorReasonPhrase` and **Value** to `Requested user does not exist`. ![Error Handling Configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-error-studio-5.png) 13. Save your Mule app. 14. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 15. In cURL test the URL `[http://localhost:8081/login?user=mule](http://localhost:8081/login?user=mule)` If the user is valid, the result returns `200 Log in Successful!` otherwise, returns `404 Requested user does not exist`. ## XML for HTTP Error Status Code and Reason Phrase Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # HTTP/2 Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Get faster, more efficient, and secure communication in Mule apps with HTTP/2 support in HTTP Connector. HTTP/2 is the second major version of the Hypertext Transfer Protocol, the foundation of communication for the World Wide Web. Published as RFC 7540, HTTP/2 addresses the performance limitations of HTTP/1.1 by improving speed, efficiency, and security. > [!NOTE] HTTP/2 features in Mule runtime 4.10.0 and later are in early availability and subject to > change. ## Before You Begin To use this feature, you must have: - Mule runtime 4.10.0 or later - HTTP Connector version 1.11.0 or later - The `mule.http.service.implementation=NETTY` system property set - Runtime Fabric or a Hybrid Standalone environment > [!IMPORTANT] HTTP/2 support is available only on Anypoint Runtime Fabric and Hybrid Standalone > environments. ## Key Features HTTP/2 support improves performance with these capabilities: - **Multiplexing** Sends multiple requests and responses over a single TCP connection at the same time, avoiding HTTP/1.1 head-of-line blocking and reducing latency. - **Header Compression (HPACK)** Compresses request and response headers to reduce data transfer size and speed up load times. - **Binary Protocol** Uses binary framing instead of text representation for more efficient communication. ## Backward Compatibility - Apps that work with HTTP/1 continue to work without changes. If you don’t modify the connector configuration, HTTP/1.1 remains the default protocol. - Autogenerated API proxies continue to use HTTP/1.1 unless you customize the proxy configuration to enable HTTP/2. ## Wire Logging Wire logging uses the same configuration as HTTP/1.1. Because HTTP/2 is a binary protocol, log output looks different: ```xml ``` ### Example: HTTP/2 Wire Logging Output When HTTP/2 wire logging is enabled, Mule logs both the binary frames exchanged between the client and server and the decoded data for readability. Because HTTP/2 is a binary protocol, the output includes hexadecimal representations of each frame. ```log DEBUG [http.listener.08] org.mule.service.http.impl.service.HttpMessageLogger.h2ListenerConfig: [6b24f7f9, L:/127.0.0.1:8081 - R:/127.0.0.1:57672] READ: 117B +-------------------------------------------------+ |00000000| 50 52 49 20 2a 20 48 54 54 50 2f 32 2e 30 0d 0a |PRI * HTTP/2.0..| |00000010| 0d 0a 53 4d 0d 0a 0d 0a ... |..SM... | DEBUG [http.listener.08] org.mule.service.http.impl.service.HttpMessageLogger.h2ListenerConfig: WRITE: 36B |00000000| 52 65 71 75 65 73 74 20 70 72 6f 74 6f 63 6f 6c |Request protocol| |00000010| 20 76 65 72 73 69 6f 6e 20 77 61 73 3a 20 48 54 | version was: HT| |00000020| 54 50 2f 32 |TP/2 | ``` The log shows these details: - The `PRI * HTTP/2.0` connection preface sent by the client. - Binary frame content in hexadecimal form. - Mule’s decoded payload returned to the client (`Request protocol version was: HTTP/2`). - `READ` entries correspond to inbound frames, and `WRITE` entries are outbound frames. ## Configuration Structure Enable HTTP/2 support by adding the `` element to your connection configuration. You can enable or disable HTTP/1.1 and HTTP/2 independently with this element. ### Basic Configuration Example Use this configuration to enable both HTTP/1.1 and HTTP/2 support on the same listener connection. ```xml ``` ### HTTP/2 Configuration Parameters The `` element supports these parameters:
ParameterTypeDefaultRangeDescription

enable

Boolean

true

-

Enables or disables HTTP/2 support.

headerTableSize

Long

4096

0 - 4,294,967,295

Maximum size of header compression table in octets.

maxConcurrentStreams

Long

No limit

100 - 4,294,967,295

Maximum number of concurrent streams.

initialWindowSize

Integer

65535

0 - 2,147,483,647

Initial flow-control window size in octets.

maxFrameSize

Integer

16384

16,384 - 16,777,215

Maximum frame payload size in octets.

maxHeaderListSize

Long

8192

0 - 4,294,967,295

Maximum header list size in octets.

### Configuration Examples These examples show how to enable and configure HTTP/2 support in different scenarios. #### Basic HTTP/2 with SSL (Recommended) Use this configuration to enable HTTP/2 over HTTPS with TLS for secure communication. ```xml ``` When using SSL, TLS negotiates which HTTP version to use through the [ALPN extension](https://datatracker.ietf.org/doc/html/rfc7301#section-3). #### HTTP/2 Cleartext (H2C) with Upgrade Use this configuration to enable HTTP/2 support with cleartext on the listener connection. ```xml ``` #### HTTP/2 Cleartext with Prior Knowledge (H2C Prior Knowledge) This configuration shows how to enable HTTP/2 on a server without HTTP/1 support, allowing HTTP clients to use HTTP/2 with prior knowledge. ```xml ``` When you enable only HTTP/2 on the server, HTTP clients can send only HTTP/2 requests with prior knowledge. An HTTP/1 request with “Upgrade: h2c” header is rejected by that server. #### Fully Parameterized HTTP/2 Configuration This example shows all configurable HTTP/2 parameters, including recommended values from the HTTP/2 specification. ```xml ``` These parameters configure HTTP/2 support and use recommended values from the [HTTP/2 Settings](https://datatracker.ietf.org/doc/html/rfc9113#SETTINGS). ### Protocol Detection in Flows You can detect which HTTP version a request used by checking `attributes.version`: ```xml ``` This flow can return: - `Request protocol version was: HTTP/2` - `Request protocol version was: HTTP/1.1` ## Configuration Guidelines These guidelines help you configure HTTP/2 settings for compatibility, security, and performance. ### Protocol Compatibility Use HTTP/2 with SSL whenever possible. The server negotiates the protocol using ALPN (H2 or HTTP/1.1). ### Parameter Tuning HTTP/2 settings are recommendations to the implementation and aren’t guaranteed to be honored. ### Security Use SSL to secure communications. ### Validation Rules The connector validates HTTP/2 parameters according to RFC 7540: - `headerTableSize`: 0 - 4,294,967,295 - `maxConcurrentStreams`: 100 - 4,294,967,295 (minimum recommended: 100) - `initialWindowSize`: 0 - 2,147,483,647 - `maxFrameSize`: 16,384 - 16,777,215 - `maxHeaderListSize`: 0 - 4,294,967,295 ## Troubleshooting Common issues and solutions: - HTTP/2 not working Confirm Mule runtime 4.10.0+ and HTTP Connector 1.11.0+ are installed. - Connection failures Verify TLS configuration for HTTPS connections. - Parameter validation errors Ensure parameter values are within the supported ranges. - Protocol negotiation failures Make sure the client and server both support the same protocols. ### Testing HTTP/2 Configuration Use this MUnit test to confirm HTTP/2 is working: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # HTTP/2 Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Get faster, more efficient, and secure communication in Mule apps with HTTP/2 support in HTTP Connector. HTTP/2 is the second major version of the Hypertext Transfer Protocol, the foundation of communication for the World Wide Web. Published as RFC 7540, HTTP/2 addresses the performance limitations of HTTP/1.1 by improving speed, efficiency, and security. > [!NOTE] HTTP/2 features in Mule runtime 4.10.0 and later are in early availability and subject to > change. ## Before You Begin To use this feature, you must have: - Mule runtime 4.10.0 or later - HTTP Connector version 1.11.0 or later - The `mule.http.service.implementation=NETTY` system property set - Runtime Fabric or a Hybrid Standalone environment > [!IMPORTANT] HTTP/2 support is available only on Anypoint Runtime Fabric and Hybrid Standalone > environments. ## Key Features HTTP/2 support improves performance with these capabilities: - **Multiplexing** Sends multiple requests and responses over a single TCP connection at the same time, avoiding HTTP/1.1 head-of-line blocking and reducing latency. - **Header Compression (HPACK)** Compresses request and response headers to reduce data transfer size and speed up load times. - **Binary Protocol** Uses binary framing instead of text representation for more efficient communication. ## Backward Compatibility - Apps that work with HTTP/1 continue to work without changes. If you don’t modify the connector configuration, HTTP/1.1 remains the default protocol. - Autogenerated API proxies continue to use HTTP/1.1 unless you customize the proxy configuration to enable HTTP/2. ## Wire Logging Wire logging uses the same configuration as HTTP/1.1. Because HTTP/2 is a binary protocol, log output looks different: ```xml ``` ### Example: HTTP/2 Wire Logging Output When HTTP/2 wire logging is enabled, Mule logs both the binary frames exchanged between the client and server and the decoded data for readability. Because HTTP/2 is a binary protocol, the output includes hexadecimal representations of each frame. ```log DEBUG [http.listener.08] org.mule.service.http.impl.service.HttpMessageLogger.h2ListenerConfig: [6b24f7f9, L:/127.0.0.1:8081 - R:/127.0.0.1:57672] READ: 117B +-------------------------------------------------+ |00000000| 50 52 49 20 2a 20 48 54 54 50 2f 32 2e 30 0d 0a |PRI * HTTP/2.0..| |00000010| 0d 0a 53 4d 0d 0a 0d 0a ... |..SM... | DEBUG [http.listener.08] org.mule.service.http.impl.service.HttpMessageLogger.h2ListenerConfig: WRITE: 36B |00000000| 52 65 71 75 65 73 74 20 70 72 6f 74 6f 63 6f 6c |Request protocol| |00000010| 20 76 65 72 73 69 6f 6e 20 77 61 73 3a 20 48 54 | version was: HT| |00000020| 54 50 2f 32 |TP/2 | ``` The log shows these details: - The `PRI * HTTP/2.0` connection preface sent by the client. - Binary frame content in hexadecimal form. - Mule’s decoded payload returned to the client (`Request protocol version was: HTTP/2`). - `READ` entries correspond to inbound frames, and `WRITE` entries are outbound frames. ## Configuration Structure Enable HTTP/2 support by adding the `` element to your connection configuration. You can enable or disable HTTP/1.1 and HTTP/2 independently with this element. ### Basic Configuration Example Use this configuration to enable both HTTP/1.1 and HTTP/2 support on the same listener connection. ```xml ``` ### HTTP/2 Configuration Parameters The `` element supports these parameters:
ParameterTypeDefaultRangeDescription

enable

Boolean

true

-

Enables or disables HTTP/2 support.

headerTableSize

Long

4096

0 - 4,294,967,295

Maximum size of header compression table in octets.

maxConcurrentStreams

Long

No limit

100 - 4,294,967,295

Maximum number of concurrent streams.

initialWindowSize

Integer

65535

0 - 2,147,483,647

Initial flow-control window size in octets.

maxFrameSize

Integer

16384

16,384 - 16,777,215

Maximum frame payload size in octets.

maxHeaderListSize

Long

8192

0 - 4,294,967,295

Maximum header list size in octets.

### Configuration Examples These examples show how to enable and configure HTTP/2 support in different scenarios. #### Basic HTTP/2 with SSL (Recommended) Use this configuration to enable HTTP/2 over HTTPS with TLS for secure communication. ```xml ``` When using SSL, TLS negotiates which HTTP version to use through the [ALPN extension](https://datatracker.ietf.org/doc/html/rfc7301#section-3). #### HTTP/2 Cleartext (H2C) with Upgrade Use this configuration to enable HTTP/2 support with cleartext on the listener connection. ```xml ``` #### HTTP/2 Cleartext with Prior Knowledge (H2C Prior Knowledge) This configuration shows how to enable HTTP/2 on a server without HTTP/1 support, allowing HTTP clients to use HTTP/2 with prior knowledge. ```xml ``` When you enable only HTTP/2 on the server, HTTP clients can send only HTTP/2 requests with prior knowledge. An HTTP/1 request with “Upgrade: h2c” header is rejected by that server. #### Fully Parameterized HTTP/2 Configuration This example shows all configurable HTTP/2 parameters, including recommended values from the HTTP/2 specification. ```xml ``` These parameters configure HTTP/2 support and use recommended values from the [HTTP/2 Settings](https://datatracker.ietf.org/doc/html/rfc9113#SETTINGS). ### Protocol Detection in Flows You can detect which HTTP version a request used by checking `attributes.version`: ```xml ``` This flow can return: - `Request protocol version was: HTTP/2` - `Request protocol version was: HTTP/1.1` ## Configuration Guidelines These guidelines help you configure HTTP/2 settings for compatibility, security, and performance. ### Protocol Compatibility Use HTTP/2 with SSL whenever possible. The server negotiates the protocol using ALPN (H2 or HTTP/1.1). ### Parameter Tuning HTTP/2 settings are recommendations to the implementation and aren’t guaranteed to be honored. ### Security Use SSL to secure communications. ### Validation Rules The connector validates HTTP/2 parameters according to RFC 7540: - `headerTableSize`: 0 - 4,294,967,295 - `maxConcurrentStreams`: 100 - 4,294,967,295 (minimum recommended: 100) - `initialWindowSize`: 0 - 2,147,483,647 - `maxFrameSize`: 16,384 - 16,777,215 - `maxHeaderListSize`: 0 - 4,294,967,295 ## Troubleshooting Common issues and solutions: - HTTP/2 not working Confirm Mule runtime 4.10.0+ and HTTP Connector 1.11.0+ are installed. - Connection failures Verify TLS configuration for HTTPS connections. - Parameter validation errors Ensure parameter values are within the supported ranges. - Protocol negotiation failures Make sure the client and server both support the same protocols. ### Testing HTTP/2 Configuration Use this MUnit test to confirm HTTP/2 is working: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 keywords: anypoint, connectors, transports --- # Load a Static Resource Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Connector for HTTP (HTTP Connector) **Load static resource** operation enables you to load a static resource, such as your home page or a script. You can configure the operation by setting the path and file name of a resource to load, and optionally set the name of another file in the same directory as the resource to use in case of failure. The following example illustrates how to configure the HTTP **Listener** source and the **Load static resource** operation to serve up static content for use with HTTP, using the request path to lookup the resource. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Load a static resource flow](/mulesoft/current/en-us/http-connector/1.10/_images/http-loadresource-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `/trigger` to start the app from the web browser. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 5. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-startapp-example-1.png) 6. Drag a **Load static resource** operation to the right of the HTTP **Listener** source. 7. Set the **Resource base path** field to `/Users/max/Sites/index.html`. 8. Set the **Default file** field to the name of a backup file in the same directory as the resource, for example `index.html`. If you need to use a relative path to the Mule project, use the variable `${app.workDir}`. For example, `resourceBasePath="${app.workDir}/images/"`. In the event of a failure, the app loads the backup file. ![HTTP Load static resource configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-loadresource-example-1.png) 9. Save your Mule app. 10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 11. In a browser window, type the URL `http://0.0.0.0:8081/trigger`. The contents of the resource appear in the browser. ## XML for Loading a Static Resource Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 keywords: anypoint, connectors, transports --- # Load a Static Resource Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Connector for HTTP (HTTP Connector) **Load static resource** operation enables you to load a static resource, such as your home page or a script. You can configure the operation by setting the path and file name of a resource to load, and optionally set the name of another file in the same directory as the resource to use in case of failure. The following example illustrates how to configure the HTTP **Listener** source and the **Load static resource** operation to serve up static content for use with HTTP, using the request path to lookup the resource. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Load a static resource flow](/mulesoft/current/en-us/http-connector/1.11/_images/http-loadresource-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `/trigger` to start the app from the web browser. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 5. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-startapp-example-1.png) 6. Drag a **Load static resource** operation to the right of the HTTP **Listener** source. 7. Set the **Resource base path** field to `/Users/max/Sites/index.html`. 8. Set the **Default file** field to the name of a backup file in the same directory as the resource, for example `index.html`. If you need to use a relative path to the Mule project, use the variable `${app.workDir}`. For example, `resourceBasePath="${app.workDir}/images/"`. In the event of a failure, the app loads the backup file. ![HTTP Load static resource configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-loadresource-example-1.png) 9. Save your Mule app. 10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 11. In a browser window, type the URL `http://0.0.0.0:8081/trigger`. The contents of the resource appear in the browser. ## XML for Loading a Static Resource Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true keywords: anypoint, connectors, transports --- # Load a Static Resource Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The Anypoint Connector for HTTP (HTTP Connector) **Load static resource** operation enables you to load a static resource, such as your home page or a script. You can configure the operation by setting the path and file name of a resource to load, and optionally set the name of another file in the same directory as the resource to use in case of failure. The following example illustrates how to configure the HTTP **Listener** source and the **Load static resource** operation to serve up static content for use with HTTP, using the request path to lookup the resource. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Load a static resource flow](/mulesoft/current/en-us/http-connector/latest/_images/http-loadresource-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `/trigger` to start the app from the web browser. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 5. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-startapp-example-1.png) 6. Drag a **Load static resource** operation to the right of the HTTP **Listener** source. 7. Set the **Resource base path** field to `/Users/max/Sites/index.html`. 8. Set the **Default file** field to the name of a backup file in the same directory as the resource, for example `index.html`. If you need to use a relative path to the Mule project, use the variable `${app.workDir}`. For example, `resourceBasePath="${app.workDir}/images/"`. In the event of a failure, the app loads the backup file. ![HTTP Load static resource configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-loadresource-example-1.png) 9. Save your Mule app. 10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 11. In a browser window, type the URL `http://0.0.0.0:8081/trigger`. The contents of the resource appear in the browser. ## XML for Loading a Static Resource Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 --- # Post a Form Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example shows how to configure Anypoint Connector for HTTP (HTTP Connector) Listener source to post a form by sending HTTP requests, which contains form parameters. To accomplish this example, you must create the Mule app, configure an HTTP global element, run the app, and post the form using curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Post a Form flow](/mulesoft/current/en-us/http-connector/1.10/_images/http-example-post-form-flow.png) Figure 1. Post a Form flow ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `submitform`. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` 5. Click **OK**. 6. Drag a **Choice** router component to the right of the HTTP **Listener** source. The **Choice** router adds conditional processing to the flow. 7. Drag a **Set Payload** component into the **When** condition box of the **Choice** router. 8. Set the **Value** field to `Sorry #[payload.'firstname'], you’re too young to register.` Note that this expression refers to one of the form parameters included in the request: `firstname`. After the connector receives the parameter, it exists in the Mule Message payload as an item within a map. 9. On the **Choice** router, select the **When** condition. 10. Set the **Expression** field to `#[server.dateTime.year-18 < payload.'yearborn']` This expression refers to one of the incoming form parameters, `yearborn`. 11. Drag another **Set Payload** component into the **Default** condition box of the **Choice** router. 12. Set the **Value** field to `Registration has been carried out successfully! Welcome #[payload.'firstname'] #[payload.'lastname']!` 13. Save your Mule app. 14. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 15. To post the form, try the following curl command: `http://localhost:8081/submitform` The post body contains the following form parameters: `firstname`, `lastname` and `yearborn`: ```text POST /submitform HTTP/1.1 User-Agent: Mule/3.6 Content-Type: application/x-www-form-urlencoded Content-Length: 32 firstname=Aaron&lastname=Aguilar+Acevedo&yearborn=1999 ``` When the HTTP Listener receives the request, it creates a Mule Message that contains a map type payload with the following key-value pairs: `firstname: Aaron` `lastname: Aguilar Acevedo` `yearborn: 1999` Note that in the case of the `lastname` parameter, while the value is encoded in the HTTP request (`Aguilar+Acevedo)`, the connector automatically decodes the value for you when placing it in the Mule Message. On any of the remaining blocks on the flow, you can easily access the value of the elements in the Map payload by using MEL expressions to refer to their corresponding keys. In the previous example, the value matching the `yearborn` key is obtained via the expression `#[payload.'yearborn']`. Depending on the value of this expression, one of two different paths is followed: - The first path sets the payload to a message that rejects the registration, referencing the value matching the `firstname` key through a similar MEL expression. - The second path accepts the registration and welcomes the user by name, referencing the `firstname` and `lastname` values. ## XML for Posting a Form App Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # Post a Form Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example shows how to configure Anypoint Connector for HTTP (HTTP Connector) Listener source to post a form by sending HTTP requests, which contains form parameters. To accomplish this example, you must create the Mule app, configure an HTTP global element, run the app, and post the form using curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Post a Form flow](/mulesoft/current/en-us/http-connector/1.11/_images/http-example-post-form-flow.png) Figure 1. Post a Form flow ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `submitform`. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` 5. Click **OK**. 6. Drag a **Choice** router component to the right of the HTTP **Listener** source. The **Choice** router adds conditional processing to the flow. 7. Drag a **Set Payload** component into the **When** condition box of the **Choice** router. 8. Set the **Value** field to `Sorry #[payload.'firstname'], you’re too young to register.` Note that this expression refers to one of the form parameters included in the request: `firstname`. After the connector receives the parameter, it exists in the Mule Message payload as an item within a map. 9. On the **Choice** router, select the **When** condition. 10. Set the **Expression** field to `#[server.dateTime.year-18 < payload.'yearborn']` This expression refers to one of the incoming form parameters, `yearborn`. 11. Drag another **Set Payload** component into the **Default** condition box of the **Choice** router. 12. Set the **Value** field to `Registration has been carried out successfully! Welcome #[payload.'firstname'] #[payload.'lastname']!` 13. Save your Mule app. 14. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 15. To post the form, try the following curl command: `http://localhost:8081/submitform` The post body contains the following form parameters: `firstname`, `lastname` and `yearborn`: ```text POST /submitform HTTP/1.1 User-Agent: Mule/3.6 Content-Type: application/x-www-form-urlencoded Content-Length: 32 firstname=Aaron&lastname=Aguilar+Acevedo&yearborn=1999 ``` When the HTTP Listener receives the request, it creates a Mule Message that contains a map type payload with the following key-value pairs: `firstname: Aaron` `lastname: Aguilar Acevedo` `yearborn: 1999` Note that in the case of the `lastname` parameter, while the value is encoded in the HTTP request (`Aguilar+Acevedo)`, the connector automatically decodes the value for you when placing it in the Mule Message. On any of the remaining blocks on the flow, you can easily access the value of the elements in the Map payload by using MEL expressions to refer to their corresponding keys. In the previous example, the value matching the `yearborn` key is obtained via the expression `#[payload.'yearborn']`. Depending on the value of this expression, one of two different paths is followed: - The first path sets the payload to a message that rejects the registration, referencing the value matching the `firstname` key through a similar MEL expression. - The second path accepts the registration and welcomes the user by name, referencing the `firstname` and `lastname` values. ## XML for Posting a Form App Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Post a Form Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example shows how to configure Anypoint Connector for HTTP (HTTP Connector) Listener source to post a form by sending HTTP requests, which contains form parameters. To accomplish this example, you must create the Mule app, configure an HTTP global element, run the app, and post the form using curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Post a Form flow](/mulesoft/current/en-us/http-connector/latest/_images/http-example-post-form-flow.png) Figure 1. Post a Form flow ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `submitform`. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` 5. Click **OK**. 6. Drag a **Choice** router component to the right of the HTTP **Listener** source. The **Choice** router adds conditional processing to the flow. 7. Drag a **Set Payload** component into the **When** condition box of the **Choice** router. 8. Set the **Value** field to `Sorry #[payload.'firstname'], you’re too young to register.` Note that this expression refers to one of the form parameters included in the request: `firstname`. After the connector receives the parameter, it exists in the Mule Message payload as an item within a map. 9. On the **Choice** router, select the **When** condition. 10. Set the **Expression** field to `#[server.dateTime.year-18 < payload.'yearborn']` This expression refers to one of the incoming form parameters, `yearborn`. 11. Drag another **Set Payload** component into the **Default** condition box of the **Choice** router. 12. Set the **Value** field to `Registration has been carried out successfully! Welcome #[payload.'firstname'] #[payload.'lastname']!` 13. Save your Mule app. 14. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 15. To post the form, try the following curl command: `http://localhost:8081/submitform` The post body contains the following form parameters: `firstname`, `lastname` and `yearborn`: ```text POST /submitform HTTP/1.1 User-Agent: Mule/3.6 Content-Type: application/x-www-form-urlencoded Content-Length: 32 firstname=Aaron&lastname=Aguilar+Acevedo&yearborn=1999 ``` When the HTTP Listener receives the request, it creates a Mule Message that contains a map type payload with the following key-value pairs: `firstname: Aaron` `lastname: Aguilar Acevedo` `yearborn: 1999` Note that in the case of the `lastname` parameter, while the value is encoded in the HTTP request (`Aguilar+Acevedo)`, the connector automatically decodes the value for you when placing it in the Mule Message. On any of the remaining blocks on the flow, you can easily access the value of the elements in the Map payload by using MEL expressions to refer to their corresponding keys. In the previous example, the value matching the `yearborn` key is obtained via the expression `#[payload.'yearborn']`. Depending on the value of this expression, one of two different paths is followed: - The first path sets the payload to a message that rejects the registration, referencing the value matching the `firstname` key through a similar MEL expression. - The second path accepts the registration and welcomes the user by name, referencing the `firstname` and `lastname` values. ## XML for Posting a Form App Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 --- # Route HTTP Requests to Different Paths Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example has multiple flows, each having an Anypoint Connector for HTTP (HTTP Connector) **Listener** source that listens for requests to different subpaths: - HTTP requests directed to `http://localhost:8081/account` are routed to the first flow. - HTTP requests directed to `http://localhost:8081/employee` are routed to the second flow. - HTTP requests that don’t match the path defined in any of the HTTP Listeners make the connector return an HTTP `404 Resource Not Found` error. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![HTTP Requests to paths flow](/mulesoft/current/en-us/http-connector/1.10/_images/request-mule-msg-map.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `account` to start the app from the web browser. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` 5. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-route-example-1.png) ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-route-example-2.png) 6. Drag a **Logger** component to the right of the HTTP **Listener** source. 7. To create the second flow, drag another HTTP **Listener** below the first flow. 8. For the **Connector configuration** field, select the same `HTTP_Listener_config` configuration created for the first HTTP **Listener** source. 9. Set **Path** to `employee`. ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-route-example-2.png) 10. Drag a **Logger** component to the right of the second HTTP **Listener** source. 11. Save your Mule app. 12. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 13. Open a browser window and type the first URL: `http://localhost:8081/account`. 14. Open another browser window and type the second URL: `http://localhost:8081/employee`. 15. Verify that the logs show the requests routed to the first and then the second flows respectively. ## XML for Routing HTTP Requests Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # Route HTTP Requests to Different Paths Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example has multiple flows, each having an Anypoint Connector for HTTP (HTTP Connector) **Listener** source that listens for requests to different subpaths: - HTTP requests directed to `http://localhost:8081/account` are routed to the first flow. - HTTP requests directed to `http://localhost:8081/employee` are routed to the second flow. - HTTP requests that don’t match the path defined in any of the HTTP Listeners make the connector return an HTTP `404 Resource Not Found` error. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![HTTP Requests to paths flow](/mulesoft/current/en-us/http-connector/1.11/_images/request-mule-msg-map.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `account` to start the app from the web browser. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` 5. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-route-example-1.png) ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-route-example-2.png) 6. Drag a **Logger** component to the right of the HTTP **Listener** source. 7. To create the second flow, drag another HTTP **Listener** below the first flow. 8. For the **Connector configuration** field, select the same `HTTP_Listener_config` configuration created for the first HTTP **Listener** source. 9. Set **Path** to `employee`. ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-route-example-2.png) 10. Drag a **Logger** component to the right of the second HTTP **Listener** source. 11. Save your Mule app. 12. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 13. Open a browser window and type the first URL: `http://localhost:8081/account`. 14. Open another browser window and type the second URL: `http://localhost:8081/employee`. 15. Verify that the logs show the requests routed to the first and then the second flows respectively. ## XML for Routing HTTP Requests Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Route HTTP Requests to Different Paths Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example has multiple flows, each having an Anypoint Connector for HTTP (HTTP Connector) **Listener** source that listens for requests to different subpaths: - HTTP requests directed to `http://localhost:8081/account` are routed to the first flow. - HTTP requests directed to `http://localhost:8081/employee` are routed to the second flow. - HTTP requests that don’t match the path defined in any of the HTTP Listeners make the connector return an HTTP `404 Resource Not Found` error. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![HTTP Requests to paths flow](/mulesoft/current/en-us/http-connector/latest/_images/request-mule-msg-map.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `account` to start the app from the web browser. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` 5. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-route-example-1.png) ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-route-example-2.png) 6. Drag a **Logger** component to the right of the HTTP **Listener** source. 7. To create the second flow, drag another HTTP **Listener** below the first flow. 8. For the **Connector configuration** field, select the same `HTTP_Listener_config` configuration created for the first HTTP **Listener** source. 9. Set **Path** to `employee`. ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-route-example-2.png) 10. Drag a **Logger** component to the right of the second HTTP **Listener** source. 11. Save your Mule app. 12. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 13. Open a browser window and type the first URL: `http://localhost:8081/account`. 14. Open another browser window and type the second URL: `http://localhost:8081/employee`. 15. Verify that the logs show the requests routed to the first and then the second flows respectively. ## XML for Routing HTTP Requests Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 --- # Route Requests Based on an HTTP Method Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure Anypoint Connector for HTTP (HTTP Connector) **Listener** operation to route requests based on an HTTP method. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Route Requests Based on an HTTP Method flow](/mulesoft/current/en-us/http-connector/1.10/_images/http-routemethod-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `requests` to start the app from the web browser. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` - **Base path**: `mypath` 5. Click **OK**. 6. Drag a **Logger** component to the right of the HTTP **Listener** source. 7. Set the **Message** field to `flow 1`. 8. Create a second flow by dragging another HTTP **Listener** source below the first flow. 9. Set the **Connector Configuration** field to `HTTP_Listener_Config`, the global element you created for the first **Listener**. 10. Set the **Path** field to `requests`. 11. In the connector configuration screen, select the **Advanced** tab, and set the **Allowed methods** field to `POST`. 12. Drag another **Logger** component to the right of the HTTP **Listener** source. 13. Set the **Message** field to `flow 2`. 14. Save your Mule app. 15. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 16. In your browser extension send an HTTP `GET` and `POST` requests to `http://localhost:8081/mypath/requests`. The `GET` request response is `flow 1`. The `POST` request response is `flow 2`. 17. Send a `DELETE` request. The `405 Method Not Allowed` message is returned because `DELETE` is not an allowed method. ## XML for Routing Requests Based on an HTTP Method Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # Route Requests Based on an HTTP Method Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure Anypoint Connector for HTTP (HTTP Connector) **Listener** operation to route requests based on an HTTP method. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Route Requests Based on an HTTP Method flow](/mulesoft/current/en-us/http-connector/1.11/_images/http-routemethod-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `requests` to start the app from the web browser. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` - **Base path**: `mypath` 5. Click **OK**. 6. Drag a **Logger** component to the right of the HTTP **Listener** source. 7. Set the **Message** field to `flow 1`. 8. Create a second flow by dragging another HTTP **Listener** source below the first flow. 9. Set the **Connector Configuration** field to `HTTP_Listener_Config`, the global element you created for the first **Listener**. 10. Set the **Path** field to `requests`. 11. In the connector configuration screen, select the **Advanced** tab, and set the **Allowed methods** field to `POST`. 12. Drag another **Logger** component to the right of the HTTP **Listener** source. 13. Set the **Message** field to `flow 2`. 14. Save your Mule app. 15. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 16. In your browser extension send an HTTP `GET` and `POST` requests to `http://localhost:8081/mypath/requests`. The `GET` request response is `flow 1`. The `POST` request response is `flow 2`. 17. Send a `DELETE` request. The `405 Method Not Allowed` message is returned because `DELETE` is not an allowed method. ## XML for Routing Requests Based on an HTTP Method Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Route Requests Based on an HTTP Method Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure Anypoint Connector for HTTP (HTTP Connector) **Listener** operation to route requests based on an HTTP method. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Route Requests Based on an HTTP Method flow](/mulesoft/current/en-us/http-connector/latest/_images/http-routemethod-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. Set the **Path** field to `requests` to start the app from the web browser. 3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 4. On the **General** tab, configure the following fields: - **Host**: `localhost` - **Port**: `8081` - **Base path**: `mypath` 5. Click **OK**. 6. Drag a **Logger** component to the right of the HTTP **Listener** source. 7. Set the **Message** field to `flow 1`. 8. Create a second flow by dragging another HTTP **Listener** source below the first flow. 9. Set the **Connector Configuration** field to `HTTP_Listener_Config`, the global element you created for the first **Listener**. 10. Set the **Path** field to `requests`. 11. In the connector configuration screen, select the **Advanced** tab, and set the **Allowed methods** field to `POST`. 12. Drag another **Logger** component to the right of the HTTP **Listener** source. 13. Set the **Message** field to `flow 2`. 14. Save your Mule app. 15. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 16. In your browser extension send an HTTP `GET` and `POST` requests to `http://localhost:8081/mypath/requests`. The `GET` request response is `flow 1`. The `POST` request response is `flow 2`. 17. Send a `DELETE` request. The `405 Method Not Allowed` message is returned because `DELETE` is not an allowed method. ## XML for Routing Requests Based on an HTTP Method Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 --- # Start an App from a Browser Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure the Anypoint Connector for HTTP (HTTP Connector) **Listener** source to initiate a flow. In this example, the HTTP **Listener** source listens on a specific port for every network interface on the server. Then, the **Logger** component logs the message `Hello`. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Start app from a browser flow](/mulesoft/current/en-us/http-connector/1.10/_images/http-startapp-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 3. Set the **Path** field to `/trigger` to start the app from the web browser. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 5. On the **General** tab, configure the following fields: - **Host** `All Interfaces [0.0.0.0] (default)` - **Port** `8081` 6. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-startapp-example-1.png) ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-startapp-example-2.png) 7. Drag a **Logger** component to the right of HTTP **Listener**. 8. In the **Logger** configuration screen, set the **Message** field to `Hello`. ![Logger configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-startapp-example-3.png) 9. Save your Mule app. 10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. Ensure that the console messages state that the application started correctly by looking at the message `Mule is up and kicking`. 11. Open a browser and type `http://0.0.0.0:8081/trigger`. The HTTP **Listener** source listens to the request on port `8081`, and the app starts. 12. In the Studio Console, scroll through the logs to see the `Hello` message, for example: ```console INFO 2020-01-02 13:00:00,438 [[MuleRuntime].cpuLight.15: [http].httpFlow.CPU_LITE @169a1097] [event: id] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: Hello ``` ## XML for Starting an App from a Browser Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # Start an App from a Browser Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure the Anypoint Connector for HTTP (HTTP Connector) **Listener** source to initiate a flow. In this example, the HTTP **Listener** source listens on a specific port for every network interface on the server. Then, the **Logger** component logs the message `Hello`. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Start app from a browser flow](/mulesoft/current/en-us/http-connector/1.11/_images/http-startapp-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 3. Set the **Path** field to `/trigger` to start the app from the web browser. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 5. On the **General** tab, configure the following fields: - **Host** `All Interfaces [0.0.0.0] (default)` - **Port** `8081` 6. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-startapp-example-1.png) ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-startapp-example-2.png) 7. Drag a **Logger** component to the right of HTTP **Listener**. 8. In the **Logger** configuration screen, set the **Message** field to `Hello`. ![Logger configuration](/mulesoft/current/en-us/http-connector/1.11/_images/http-startapp-example-3.png) 9. Save your Mule app. 10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. Ensure that the console messages state that the application started correctly by looking at the message `Mule is up and kicking`. 11. Open a browser and type `http://0.0.0.0:8081/trigger`. The HTTP **Listener** source listens to the request on port `8081`, and the app starts. 12. In the Studio Console, scroll through the logs to see the `Hello` message, for example: ```console INFO 2020-01-02 13:00:00,438 [[MuleRuntime].cpuLight.15: [http].httpFlow.CPU_LITE @169a1097] [event: id] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: Hello ``` ## XML for Starting an App from a Browser Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Start an App from a Browser Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt The following example illustrates how to configure the Anypoint Connector for HTTP (HTTP Connector) **Listener** source to initiate a flow. In this example, the HTTP **Listener** source listens on a specific port for every network interface on the server. Then, the **Logger** component logs the message `Hello`. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands. The following screenshot shows the Anypoint Studio app flow for this example: ![Start app from a browser flow](/mulesoft/current/en-us/http-connector/latest/_images/http-startapp-flow.png) ## Create the Mule Application To create the Mule flow: 1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it on to the canvas. The source initiates the flow by listening for incoming HTTP message attributes. 2. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 3. Set the **Path** field to `/trigger` to start the app from the web browser. 4. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app. 5. On the **General** tab, configure the following fields: - **Host** `All Interfaces [0.0.0.0] (default)` - **Port** `8081` 6. Click **OK**. ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-startapp-example-1.png) ![HTTP Listener configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-startapp-example-2.png) 7. Drag a **Logger** component to the right of HTTP **Listener**. 8. In the **Logger** configuration screen, set the **Message** field to `Hello`. ![Logger configuration](/mulesoft/current/en-us/http-connector/latest/_images/http-startapp-example-3.png) 9. Save your Mule app. 10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. Ensure that the console messages state that the application started correctly by looking at the message `Mule is up and kicking`. 11. Open a browser and type `http://0.0.0.0:8081/trigger`. The HTTP **Listener** source listens to the request on port `8081`, and the app starts. 12. In the Studio Console, scroll through the logs to see the `Hello` message, for example: ```console INFO 2020-01-02 13:00:00,438 [[MuleRuntime].cpuLight.15: [http].httpFlow.CPU_LITE @169a1097] [event: id] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: Hello ``` ## XML for Starting an App from a Browser Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.10 keywords: anypoint studio, esb, connectors, http, https, http headers, troubleshooting, rest, raml --- # Troubleshooting HTTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot Anypoint Connector for HTTP (HTTP Connector), enable wire logging and TLS debugging, ensure proper use of the `Host` header and HTTP encoding, and become familiar with commonly thrown messages. ## Enable Wire Logging Troubleshoot application performance by enabling wire logging, which logs the actual raw HTTP requests and responses in the app workflow. Then use the logs to validate the current configuration or to compare HTTP Connector behavior to that of other clients and servers. To enable HTTP wire logging: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project. 3. Open the `src/main/resources` path folder. 4. Open the `log4j2.xml` file inside the folder. 5. If the following line is already in the `log4j2.xml` file, uncomment it to enable it; otherwise, add it: ```xml ... ... ... ``` 6. Save your changes. 7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. ## Enable TLS Debugging Troubleshoot SSL failures by enabling TLS debugging, which logs SSL-related data such as connection attempts, handshakes, and negotiations. Then use the logs to determine whether the correct certificates are in place, why a cipher or protocol mismatch occurs, or why connectivity fails. To enable TLS debugging, configure the following system property: `-Djavax.net.debug=ssl`. ## Troubleshoot Host Header Misuse HTTP clients use the `Host` header to indicate the host and port number of the resource requested. The HTTP Connector **Request** operation autogenerates this mandatory header considering the configured host and port. However, servers often consider the port information optional and fail if they receive a request containing it. Report such failures to the server owner to correct. Meanwhile, work around the issue by manually modifying the **Request** operation to output a `Host` header without the port information. The following example shows a `` configuration that sends a `Host: somehost.com` header: ```xml #[{"Host" : "somehost.com"}] ``` Without the explicit header configuration, an autogenerated `Host: somehost.com:8081` would be sent. ## Troubleshoot HTTP Encoding To obtain better performance when working with streamed data, HTTP Connector sends requests and responses with the `Transfer-Encoding: chunked` encoding when the size of the data being sent is unknown. However, some HTTP clients and servers are not prepared to receive such data and fail. Report such failures to the server or client owner to correct. Meanwhile, work around the issue by manually modifying the **Listener** and **Request** operations to output `Content-Length` encoded bodies. The following example shows the HTTP **Listener** operation configured with `responseStreamingMode` `NEVER`, which indicates to use `Content-Length` encoding: ```xml ``` The following example shows an HTTP **Requester** operation configured with `requestStreamingMode` `NEVER` to use `Content-Length` encoding: ```xml ``` ## Troubleshoot OAuth2 Authorization Code Grant Type Issues If your Mule app uses OAuth2 Authorization Code Grant Type authentication and returns the `_No access token found. Verify that you have authenticated before trying to execute an operation to the API_` message, check these possible solutions: - Call Authorization URL: As per the OAuth policy, it is necessary to call the authorization URL at least once to obtain the access token. - Use an Object Store: Save the access token in an Object Store. If the token expires, retrieve a new access token using the refresh token and update the Object Store. - Use DocuSign Connector: Consider using DocuSign Connector to manage authentication and token management more effectively. ## Understand Common Throws Here is a list of common throw messages and how to interpret them: - HTTP:BAD\_REQUEST The server cannot understand the request due to invalid syntax, for example, when a header size exceeds the maximum. - HTTP:CLIENT\_SECURITY A security problem enforced by an external entity occurred. - HTTP:CONNECTIVITY A problem occurred and a connection could not be established. - HTTP:FORBIDDEN The server refuses to give the requested resource because the client does not have access rights to the content. - HTTP:INTERNAL\_SERVER\_ERROR The server encountered a situation that prevented it from fulfilling the request. - HTTP:METHOD\_NOT\_ALLOWED The server request method is not supported by the target resource. - HTTP:NOT\_ACCEPTABLE The server cannot produce a response matching the list of acceptable values defined in the request's proactive content negotiation headers. - HTTP:NOT\_FOUND The server could not find the requested resource. - HTTP:PARSING \[DEPRECATED but kept for compatibility.\] The parsing mechanism has been removed. - HTTP:RETRY\_EXHAUSTED The maximum number of retries for the operation is reached. - HTTP:SECURITY The requester authentication failed. - HTTP:SERVICE\_UNAVAILABLE The server is unable to manage the request because it is down for maintenance or overloaded. - HTTP:TIMEOUT The request sent by an http:requester timed out. - HTTP:TOO\_MANY\_REQUESTS Too many request were sent in a given amount of time. - HTTP:UNAUTHORIZED Authentication failed or has not yet been provided to get the requested response. - HTTP:UNSUPPORTED\_MEDIA\_TYPE The server does not support the media format of the requested data. - HTTP:BAD\_GATEWAY The server acting as a gateway or proxy to manage the request received an invalid response. - HTTP:GATEWAY\_TIMEOUT The server acting as a gateway or proxy to manage the request did not receive a response within the specified time. - HTTP:BASIC\_AUTHENTICATION Either the HTTP \*Request\* operation lacks basic authentication to send requests to the service, or the provided credentials are incorrect. ## See Also - [HTTP Listener Configuration Reference](https://docs.mulesoft.com/http-connector/1.10/http-listener-ref) - [HTTP Request Configuration Reference](https://docs.mulesoft.com/http-connector/1.10/http-request-ref) - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues) --- product: HTTP Connector version: 1.11 keywords: anypoint studio, esb, connectors, http, https, http headers, troubleshooting, rest, raml --- # Troubleshooting HTTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot Anypoint Connector for HTTP (HTTP Connector), enable wire logging and TLS debugging, ensure proper use of the `Host` header and HTTP encoding, and become familiar with commonly thrown messages. ## Enable Wire Logging Troubleshoot application performance by enabling wire logging, which logs the actual raw HTTP requests and responses in the app workflow. Then use the logs to validate the current configuration or to compare HTTP Connector behavior to that of other clients and servers. To enable HTTP wire logging: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project. 3. Open the `src/main/resources` path folder. 4. Open the `log4j2.xml` file inside the folder. 5. If the following line is already in the `log4j2.xml` file, uncomment it to enable it; otherwise, add it: ```xml ... ... ... ``` 6. Save your changes. 7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. ## Enable TLS Debugging Troubleshoot SSL failures by enabling TLS debugging, which logs SSL-related data such as connection attempts, handshakes, and negotiations. Then use the logs to determine whether the correct certificates are in place, why a cipher or protocol mismatch occurs, or why connectivity fails. To enable TLS debugging, configure the following system property: `-Djavax.net.debug=ssl`. ## Troubleshoot Host Header Misuse HTTP clients use the `Host` header to indicate the host and port number of the resource requested. The HTTP Connector **Request** operation autogenerates this mandatory header considering the configured host and port. However, servers often consider the port information optional and fail if they receive a request containing it. Report such failures to the server owner to correct. Meanwhile, work around the issue by manually modifying the **Request** operation to output a `Host` header without the port information. The following example shows a `` configuration that sends a `Host: somehost.com` header: ```xml #[{"Host" : "somehost.com"}] ``` Without the explicit header configuration, an autogenerated `Host: somehost.com:8081` would be sent. ## Troubleshoot HTTP Encoding To obtain better performance when working with streamed data, HTTP Connector sends requests and responses with the `Transfer-Encoding: chunked` encoding when the size of the data being sent is unknown. However, some HTTP clients and servers are not prepared to receive such data and fail. Report such failures to the server or client owner to correct. Meanwhile, work around the issue by manually modifying the **Listener** and **Request** operations to output `Content-Length` encoded bodies. The following example shows the HTTP **Listener** operation configured with `responseStreamingMode` `NEVER`, which indicates to use `Content-Length` encoding: ```xml ``` The following example shows an HTTP **Requester** operation configured with `requestStreamingMode` `NEVER` to use `Content-Length` encoding: ```xml ``` ## Troubleshoot OAuth2 Authorization Code Grant Type Issues If your Mule app uses OAuth2 Authorization Code Grant Type authentication and returns the `_No access token found. Verify that you have authenticated before trying to execute an operation to the API_` message, check these possible solutions: - Call Authorization URL: As per the OAuth policy, it is necessary to call the authorization URL at least once to obtain the access token. - Use an Object Store: Save the access token in an Object Store. If the token expires, retrieve a new access token using the refresh token and update the Object Store. - Use DocuSign Connector: Consider using DocuSign Connector to manage authentication and token management more effectively. ## Understand Common Throws Here is a list of common throw messages and how to interpret them: - HTTP:BAD\_REQUEST The server cannot understand the request due to invalid syntax, for example, when a header size exceeds the maximum. - HTTP:CLIENT\_SECURITY A security problem enforced by an external entity occurred. - HTTP:CONNECTIVITY A problem occurred and a connection could not be established. - HTTP:FORBIDDEN The server refuses to give the requested resource because the client does not have access rights to the content. - HTTP:INTERNAL\_SERVER\_ERROR The server encountered a situation that prevented it from fulfilling the request. - HTTP:METHOD\_NOT\_ALLOWED The server request method is not supported by the target resource. - HTTP:NOT\_ACCEPTABLE The server cannot produce a response matching the list of acceptable values defined in the request's proactive content negotiation headers. - HTTP:NOT\_FOUND The server could not find the requested resource. - HTTP:PARSING \[DEPRECATED but kept for compatibility.\] The parsing mechanism has been removed. - HTTP:RETRY\_EXHAUSTED The maximum number of retries for the operation is reached. - HTTP:SECURITY The requester authentication failed. - HTTP:SERVICE\_UNAVAILABLE The server is unable to manage the request because it is down for maintenance or overloaded. - HTTP:TIMEOUT The request sent by an http:requester timed out. - HTTP:TOO\_MANY\_REQUESTS Too many request were sent in a given amount of time. - HTTP:UNAUTHORIZED Authentication failed or has not yet been provided to get the requested response. - HTTP:UNSUPPORTED\_MEDIA\_TYPE The server does not support the media format of the requested data. - HTTP:BAD\_GATEWAY The server acting as a gateway or proxy to manage the request received an invalid response. - HTTP:GATEWAY\_TIMEOUT The server acting as a gateway or proxy to manage the request did not receive a response within the specified time. - HTTP:BASIC\_AUTHENTICATION Either the HTTP \*Request\* operation lacks basic authentication to send requests to the service, or the provided credentials are incorrect. ## See Also - [HTTP Listener Configuration Reference](https://docs.mulesoft.com/http-connector/1.11/http-listener-ref) - [HTTP Request Configuration Reference](https://docs.mulesoft.com/http-connector/1.11/http-request-ref) - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues) --- product: HTTP Connector version: 1.12 is-latest-version: true keywords: anypoint studio, esb, connectors, http, https, http headers, troubleshooting, rest, raml --- # Troubleshooting HTTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot Anypoint Connector for HTTP (HTTP Connector), enable wire logging and TLS debugging, ensure proper use of the `Host` header and HTTP encoding, and become familiar with commonly thrown messages. ## Enable Wire Logging Troubleshoot application performance by enabling wire logging, which logs the actual raw HTTP requests and responses in the app workflow. Then use the logs to validate the current configuration or to compare HTTP Connector behavior to that of other clients and servers. To enable HTTP wire logging: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project. 3. Open the `src/main/resources` path folder. 4. Open the `log4j2.xml` file inside the folder. 5. If the following line is already in the `log4j2.xml` file, uncomment it to enable it; otherwise, add it: ```xml ... ... ... ``` 6. Save your changes. 7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. ## Enable TLS Debugging Troubleshoot SSL failures by enabling TLS debugging, which logs SSL-related data such as connection attempts, handshakes, and negotiations. Then use the logs to determine whether the correct certificates are in place, why a cipher or protocol mismatch occurs, or why connectivity fails. To enable TLS debugging, configure the following system property: `-Djavax.net.debug=ssl`. ## Troubleshoot Host Header Misuse HTTP clients use the `Host` header to indicate the host and port number of the resource requested. The HTTP Connector **Request** operation autogenerates this mandatory header considering the configured host and port. However, servers often consider the port information optional and fail if they receive a request containing it. Report such failures to the server owner to correct. Meanwhile, work around the issue by manually modifying the **Request** operation to output a `Host` header without the port information. The following example shows a `` configuration that sends a `Host: somehost.com` header: ```xml #[{"Host" : "somehost.com"}] ``` Without the explicit header configuration, an autogenerated `Host: somehost.com:8081` would be sent. For default-port behavior and configuration options, see [Configure the Host Header](https://docs.mulesoft.com/http-connector/latest/http-request-ref#configure-host-header). ## Troubleshoot HTTP Encoding To obtain better performance when working with streamed data, HTTP Connector sends requests and responses with the `Transfer-Encoding: chunked` encoding when the size of the data being sent is unknown. However, some HTTP clients and servers are not prepared to receive such data and fail. Report such failures to the server or client owner to correct. Meanwhile, work around the issue by manually modifying the **Listener** and **Request** operations to output `Content-Length` encoded bodies. The following example shows the HTTP **Listener** operation configured with `responseStreamingMode` `NEVER`, which indicates to use `Content-Length` encoding: ```xml ``` The following example shows an HTTP **Requester** operation configured with `requestStreamingMode` `NEVER` to use `Content-Length` encoding: ```xml ``` ## Troubleshoot OAuth2 Authorization Code Grant Type Issues If your Mule app uses OAuth2 Authorization Code Grant Type authentication and returns the `_No access token found. Verify that you have authenticated before trying to execute an operation to the API_` message, check these possible solutions: - Call Authorization URL: As per the OAuth policy, it is necessary to call the authorization URL at least once to obtain the access token. - Use an Object Store: Save the access token in an Object Store. If the token expires, retrieve a new access token using the refresh token and update the Object Store. - Use DocuSign Connector: Consider using DocuSign Connector to manage authentication and token management more effectively. ## Troubleshoot Remote Host Closed Connection Errors If the HTTP Request operation fails with `Remote host closed connection` or `Remotely closed`, HTTP Connector might be reusing a stale connection from its pool. This happens when **Connection Idle Timeout** (`connectionIdleTimeout`) is longer than the idle timeout of the remote system, so the remote system closes the connection before the connector does. To resolve this, set **Connection Idle Timeout** lower than the remote system’s idle or keep-alive timeout, for example, between `10000` and `15000` milliseconds. Salesforce typically closes connections after 30 seconds of inactivity. ```xml ``` ## Understand Common Throws Here is a list of common throw messages and how to interpret them: - HTTP:BAD\_REQUEST The server cannot understand the request due to invalid syntax, for example, when a header size exceeds the maximum. - HTTP:CLIENT\_SECURITY A security problem enforced by an external entity occurred. - HTTP:CONNECTIVITY A problem occurred and a connection could not be established. - HTTP:FORBIDDEN The server refuses to give the requested resource because the client does not have access rights to the content. - HTTP:INTERNAL\_SERVER\_ERROR The server encountered a situation that prevented it from fulfilling the request. - HTTP:METHOD\_NOT\_ALLOWED The server request method is not supported by the target resource. - HTTP:NOT\_ACCEPTABLE The server cannot produce a response matching the list of acceptable values defined in the request's proactive content negotiation headers. - HTTP:NOT\_FOUND The server could not find the requested resource. - HTTP:PARSING \[DEPRECATED but kept for compatibility.\] The parsing mechanism has been removed. - HTTP:RETRY\_EXHAUSTED The maximum number of retries for the operation is reached. - HTTP:SECURITY The requester authentication failed. - HTTP:SERVICE\_UNAVAILABLE The server is unable to manage the request because it is down for maintenance or overloaded. - HTTP:TIMEOUT The request sent by an http:requester timed out. - HTTP:TOO\_MANY\_REQUESTS Too many request were sent in a given amount of time. - HTTP:UNAUTHORIZED Authentication failed or has not yet been provided to get the requested response. - HTTP:UNSUPPORTED\_MEDIA\_TYPE The server does not support the media format of the requested data. - HTTP:BAD\_GATEWAY The server acting as a gateway or proxy to manage the request received an invalid response. - HTTP:GATEWAY\_TIMEOUT The server acting as a gateway or proxy to manage the request did not receive a response within the specified time. - HTTP:BASIC\_AUTHENTICATION Either the HTTP \*Request\* operation lacks basic authentication to send requests to the service, or the provided credentials are incorrect. ## See Also - [HTTP Listener Configuration Reference](https://docs.mulesoft.com/http-connector/latest/http-listener-ref) - [HTTP Request Configuration Reference](https://docs.mulesoft.com/http-connector/latest/http-request-ref) - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues) --- product: HTTP Connector version: 1.10 --- # Using Anypoint Code Builder to Configure HTTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Cloud IDE (Beta) is scheduled for retirement on August 31, 2026. August 30, 2026 is the last day you can access Cloud IDE (Beta). Download your projects to work from Desktop IDE. Learn more in [Migrate a Project from Cloud IDE to Desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/int-import-mule-project#migrate-cloud-to-desktop). To use Anypoint Code Builder to configure a connector or module, create a basic integration project in Anypoint Code Builder, add connectors and other components to your Mule application to process your business logic, and configure the attributes. ## Before You Begin Before creating an integration project, you must: - [Set up and access the Anypoint Code Builder web or desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/start-acb) - Have credentials to access the connector’s API - Ensure that the Visual Studio Code Extension Pack for Java is installed. To use this connector, you must be familiar with: - The connector’s API - Anypoint Connectors - Mule runtime engine (Mule) ## Creating a New Integration Project To create a new integration project: 1. In the activity bar of the IDE, click the ![Anypoint Code Builder icon](/mulesoft/current/en-us/connectors/_images/acb-icon-ms-logo.png) (**Anypoint Code Builder**) icon. 2. From **Quick Actions**, click **Develop an Integration**: ![Develop an Integration link highlighted in the Getting started section](/mulesoft/current/en-us/anypoint-code-builder/_images/develop-integration-option-mat.png) 3. Complete the following in the **Develop an Integration** form:
AttributeValue

Project Name

Unique name for your project.

This name is used as the title and name of the integration project file. For example, if the project name is "Salesforce Integration," the project file name is salesforce-integration.

Project Location

Your home directory or another directory you create. Click Browse to select a different directory for the integration project.

Don’t create the project within another project directory.

4. Select the type of project to create by selecting either the **Empty Project** or **Template or Example** card. 5. Select the **Mule runtime** and **Java Version** for your app. 6. Click **Create Project**. ## Adding the Connector to Your Integration Project Anypoint Connectors provide operations for retrieving, modifying, and sending data to and from systems. In addition to the [built-in connectors](https://docs.mulesoft.com/anypoint-code-builder/acb-reference#builtin-connectors) that Anypoint Code Builder provides, you can download many other connectors from Anypoint Exchange. To import a connector from Exchange and add it to your configuration: 1. In the Explorer view, open the configuration XML file for your project, such as `my-project-name.xml`. 2. Click the ![Show Mule graphical mode icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-tree-view.png) (**Show Mule graphical mode**) icon in the activity bar to open the canvas UI if it doesn’t open automatically. 3. Add the connector the same way you added other components from the canvas UI: 1. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 2. In the **Add Component** panel, click **Connectors**. 3. Click the connector name and then click the operation to add, such as **Publish**: ![Add Publish operation from Anypoint MQ Connector](/mulesoft/current/en-us/anypoint-code-builder/_images/int-add-connector-operation.png) If the connector is not available locally, click the ![Search in Exchange icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-search-exchange.png) (**Search in Exchange**) toggle: ![Search in Exchange toggle](/mulesoft/current/en-us/anypoint-code-builder/_images/int-connector-search-exchange.png)
1Search locally
2Search in Exchange
4. Select the connector to add to your project. 5. Select the operation from the **Add Component** panel. Adding a connector to an integration project does not make that connector available to other projects in your Anypoint Code Builder workspace. ## Configuring the Trigger For the Flow A trigger (source) starts the flow when specified conditions are met. If a connector has its own associated sources, you can use a connector-specific trigger to initiate the flow. Each connector trigger has a unique configuration. You can configure the following sources for this connector: - **HTTP > Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met For example, to configure an HTTP Listener trigger, follow these steps: 1. Click the **Listener** component on the canvas UI. 2. (Optional) Click the edit icon to change the name of the **Listener** component. 3. (Optional) If you created a configuration file for the connector, select it. 4. In the **General** tab, in the **Path** field, enter the relative path for the path set in the HTTP configuration element. See [Configure Paths](https://docs.mulesoft.com/http-connector/latest/http-listener-ref#configure-paths). 5. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Allowed methods

To allow all HTTP methods (default), do not define this attribute. To restrict certain methods, specify all allowed HTTP methods, for example, GET, POST, as a comma-separated list.

No

Response streaming mode

Whether to use streaming when the response is sent.

No

Output MIME type

MIME type of the payload that this component outputs.

No

Parameters

Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.

No

Output encoding

Encoding of the payload that this component outputs.

No

Streaming Strategy

Configures the way data streams are consumed in Mule apps.

No

Primary node only

Select this option to execute the Listener trigger on the primary node only when running in a cluster.

No

Redelivery policy

Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.

No

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation.

No

Response

See HTTP Response Attributes.

No

Error Response

HTTP error response returns a status code for the error.

No

Body

Body of the error message.

No

Headers

Headers to include in the error message.

No

Status code

Status code of the error response, for example, 500.

No

Reason phrase

Reason for the error, for example, Gateway Timeout or Internal Server Error.

No

## Configuring a Connector in XML Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Code Builder: - If you manually code a Mule runtime engine (Mule) app in XML from the Anypoint Code Builder XML editor, you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. - If you add the connector in Anypoint Code Builder, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file. This example shows how the namespace statements are placed in the `` XML block: ```xml ``` The Apache Maven `pom.xml` file generated by Anypoint Code Builder contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml {group-id-exchange} {artifact-id-exchange} x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for the connector. 4. Select the connector. 5. Click **Dependency Snippets**. ## Adding Components to Your Project Add components to your integration project to build a flow: 1. In the **Explorer** view, open the XML file for your project, such as `my-project-name.xml`. 2. Select **Build a Flow** from the start card to create an empty flow: ![Anypoint Code Builder canvas with starting cards with the options to start from scratch, build a flow, or build a subflow](/mulesoft/current/en-us/connectors/_images/acb-build-flow.png) 3. Change the name of the flow: 1. Click **Flow**. 2. Click the edit icon. ![Arrow pointing to the flow name edit pencil icon](/mulesoft/current/en-us/connectors/_images/acb-change-flow-name.png) 3. Enter the flow name, and click the checkmark. 4. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 5. In the **Add Component** panel, search for and select your component from the results. The following example shows the **Listener** component from the **HTTP** search results: ![Listener component highlighted in the Add Component section](/mulesoft/current/en-us/anypoint-code-builder/_images/main-tutorial-add-first-listener.png) The configuration XML file now includes the XML for the HTTP Listener into the `` element, for example: ```XML ``` ## Adding a Global Configuration Add another component, this time using the XML configuration menu. For example, add the `` component from a snippet. For more information about snippets, see [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components). 1. In the configuration XML, place your cursor before the `` element and type `http`. Ensure that the cursor is not inside the `` element. 2. Type `http`, and select the `http:listener-config` snippet: ![http:listener-config snippet highlighted in the configuration XML menu](/mulesoft/current/en-us/anypoint-code-builder/_images/add-http-config-snippet.png) The snippet adds the following code: ```xml ``` ## Configuring Authentication for the Connector The Anypoint Connector for HTTP (HTTP Connector) **Request** operation supports connecting a Mule client app to a service that requires any of the following types of authentication: - Basic Authentication - Digest Authentication - NTLM Authentication - OAuth2 Authorization Code Grant Type Authentication ### HTTP XML Authentication Setup Configure HTTP Connector authentication in the XML editor. These are the XML values for HTTP Connector authentication:
Authentication TypeXML Value

Basic Authentication

<http:authentication >
  <http:basic-authentication
  username="UN" password="PW"/>
</http:authentication>

NTLM Authentication

<http:authentication >
  <http:ntlm-authentication
  domain="DM" workstation="WS"
  username="UN" password="PW" />
</http:authentication>

Digest Authentication

<http:authentication >
  <http:digest-authentication
  username="UN" password="PW"/>
</http:authentication>

OAuth 2.0

<http:listener-config name="HTTP_Listener_Configuration"
                      host="0.0.0.0" port="8081" basePath="/github"/>
<http:request-config name="HTTP_Request_Configuration"
                     protocol="HTTPS" host="api.github.com" port="443">
    <http:authentication>
        <oauth:authorization-code-grant-type
        externalCallbackUrl="http://myapp.mycompany.com:8082/callback"
        localAuthorizationUrl="http://localhost:8082/login"
        authorizationUrl="https://github.com/login/oauth/authorize"
        clientId="CLIENT_ID"
        clientSecret="CLIENT_SECRET"
        tokenUrl="https://github.com/login/oauth/access_token" />
    </http:authentication>
</http:request-config>
## Configuring the Component Attributes After you add components to your integration project, configure the attributes in the component UI, or configure the attributes directly in the XML code editor. Connector XML tags start with a namespace followed by an operation, following the syntax `namespace:operation`, such as `` for a **Select** operation in Anypoint Connector for Database (Database Connector). You can use autocomplete from an expression (**fx**) field for a component to select DataWeave functions from the Core module and other values accepted in this field. ### Configuring the HTTP Listener The Anypoint Connector for HTTP (HTTP Connector) **Listener** component enables you to set up an HTTP server and trigger flows when receiving HTTP requests. To configure the HTTP **Listener** attributes in the UI, see [Configuring the Trigger For the Flow](#configuring-http-trigger). ### Configuring the Basic Security Filter The **Basic security filter** component authenticates received HTTP requests. Use this component after a **Listener** component in your integration flow. 1. Click the **Basic security filter** component on the canvas. 2. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Realm

Authentication realm.

Yes

Security Provider

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Basic Security Filter.

No

Attributes

HTTP Request attributes defined in the HTTP Listener source to check the Authorization header.

No

### Configuring the HTTP Request The Anypoint Connector for HTTP (HTTP Connector) **Request** operation enables you to consume an external HTTP service using the default `GET` method. Otherwise, you can choose which methods the operation accepts. To configure the attributes for HTTP **Request** in the Anypoint Code Builder UI: 1. Click the **Request** component on the canvas. 2. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Method

To allow all HTTP methods (default), do not define this attribute. To restrict certain methods, specify all allowed HTTP methods, for example, GET, POST, as a comma-separated list.

No

URI Settings URL

URL to send the request to.

No

URI Settings Path

Path for where to send the request.

No

Request Body

Body of the request response message.

No

Request Headers

Headers to include in the response message.

No

URI Parameters

URI parameters used to create the request.

No

Query Parameters

Query parameters to include in the request.

No

Correlations ID

Defines whether to include an outbound correlation ID in the request.

No

3. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Output MIME type

MIME type of the payload this component outputs.

No

Parameters

Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.

No

Output encoding

Encoding of the payload this component outputs.

No

Streaming Strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Configuring the Streaming Strategy in XML.

No

Follow redirects

Specifies whether or not to follow redirects.

No

Send body mode

Specifies whether the request contains a body. Select Auto to specify that the behavior is determined by the defined allowed HTTP methods (GET, HEAD, and OPTIONS do not send a body).

No

Request streaming mode

Defines whether the request is sent using streaming.

No

Response timeout

Specifies the maximum time in milliseconds that the request element blocks the execution of the flow waiting for the HTTP response.

No

Response validator

Configures default error handling for the request. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Success Status Code Validator and Failure Status Code Validator.

No

Target Variable

Name of the variable on which the operation’s output is placed.

No

Target Value

An expression that’s evaluated against the operation’s output. The outcome of that expression is stored in the target variable.

No

Error Mappings

This attribute is not currently enabled.

No

Reconnection Strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect, Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Load Static Resource The static resource serves static content to use with HTTP. The request path is used to look up the resource. To configure the attributes for HTTP **Load static resource** in the Anypoint Code Builder UI: 1. Click the **Load static resource** component on the canvas. 2. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Resource base path

The base path of the resource that serves up the content, for example, /Users/maxthemule/ resources.

Yes

Default file

The default file to serve when a directory is specified. The default is index.html.

No

Attributes

The HTTP request attributes defined in the HTTP Listener source to check the required resources.

No

3. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Output MIME type

MIME type of the payload this component outputs.

No

Parameters

Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.

No

Output encoding

Encoding of the payload this component outputs.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

This attribute is not currently enabled.

No

## XML Examples ### Configuring the Reconnection Strategy in XML The following is an XML example of a standard reconnection strategy setting the count of reconnection attempts before failing to `5` and setting `failsDeployment` to true, which causes the application deployment to fail if the connection test fails. Because a frequency is not specified, the retry interval is the default of every 2000 ms: ```xml ``` The following is an XML example of a reconnect forever strategy where the connector attempts to reconnect every 4000 ms for as long as the application runs: ```xml ``` ### Configuring the Streaming Strategy in XML You can configure how Mule handles streams with streaming strategies. ### File-Stored Repeatable Stream The following is an XML example of reading a file that is configured with a 1 MB buffer: ```xml ``` If you consistently process a file that’s no larger than 10 KB, you can save memory by reducing the `inMemorySize` attribute: ```xml ``` ### In-Memory Repeatable Stream The following XML example shows an in-memory repeatable stream with a 512 KB initial size, which grows at a rate of 256 KB and allows up to 2000 KB (2 MB) of content in memory: ```xml ``` ## Testing an HTTP Listener Connection To test an HTTP Listener connection, click **Test Connection** in the configuration XML: ![HTTP Listener Test Connection link in the configuration XML](/mulesoft/current/en-us/anypoint-code-builder/_images/http-listener-test-connection.png) The status bar shows the progress: - **Verifying connection inbound-request** indicates that the test is in progress. - **Connection is valid** indicates a successful connection. - **Invalid Connection Got status code: 500 when trying to resolve a Mule Runtime operation** indicates a connection error. A common code `500` error is `port 8081: Address already in use`. For port conflicts, configure a different port, such as `8082`, and retest the connection. Before publishing, run your application in debug mode. ## Creating a New Configuration XML File Anypoint Code Builder creates the initial Mule configuration XML file in `src/main/mule` within the Mule project. This file contains global configurations and flow structures. You can create additional configuration files, for example, to store global configurations. To create a new XML configuration file: 1. In the Explorer view, right-click the **mule** folder (`src/main/mule`) and select **New File**. Alternatively, use the menu. Show me how Select the `mule` folder, and then: - In the desktop IDE, select **File** > **New Mule Configuration File**. - In the cloud IDE, click the ![](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-menu.png) (menu) icon, and select **File** > **New File**. 2. Enter a name for the new file with the `.xml` extension. 3. In the Editor view for the new file, press Ctrl+Space to display available options. 4. Select **Empty mule configuration**: ![New Mule configuration option in auto-correct](/mulesoft/current/en-us/anypoint-code-builder/_images/int-new-mule-config.png) This command adds the following code to the file: ```xml ``` ## See Also - [Anypoint Code Builder Overview](https://docs.mulesoft.com/anypoint-code-builder/) - [Creating Integrations](https://docs.mulesoft.com/anypoint-code-builder/int-create-integrations) - [Using Anypoint Code Builder to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-acb) - [Anypoint Code Builder Components and Commands Reference](https://docs.mulesoft.com/anypoint-code-builder/acb-reference) - [Defining and Securing Properties for a Mule Application](https://docs.mulesoft.com/anypoint-code-builder/int-create-secure-configs) - [Triggering Flows in Your Development Environment](https://docs.mulesoft.com/anypoint-code-builder/int-trigger-flows) - [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components) - [Debugging Mule Applications](https://docs.mulesoft.com/anypoint-code-builder/int-debug-mule-apps) - [Salesforce Help](https://help.salesforce.com) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation) - [Configure Streaming Strategies](https://docs.mulesoft.com/mule-runtime/latest/streaming-about) --- product: HTTP Connector version: 1.11 --- # Using Anypoint Code Builder to Configure HTTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Cloud IDE (Beta) is scheduled for retirement on August 31, 2026. August 30, 2026 is the last day you can access Cloud IDE (Beta). Download your projects to work from Desktop IDE. Learn more in [Migrate a Project from Cloud IDE to Desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/int-import-mule-project#migrate-cloud-to-desktop). To use Anypoint Code Builder to configure a connector or module, create a basic integration project in Anypoint Code Builder, add connectors and other components to your Mule application to process your business logic, and configure the attributes. ## Before You Begin Before creating an integration project, you must: - [Set up and access the Anypoint Code Builder web or desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/start-acb) - Have credentials to access the connector’s API - Ensure that the Visual Studio Code Extension Pack for Java is installed. To use this connector, you must be familiar with: - The connector’s API - Anypoint Connectors - Mule runtime engine (Mule) ## Creating a New Integration Project To create a new integration project: 1. In the activity bar of the IDE, click the ![Anypoint Code Builder icon](/mulesoft/current/en-us/connectors/_images/acb-icon-ms-logo.png) (**Anypoint Code Builder**) icon. 2. From **Quick Actions**, click **Develop an Integration**: ![Develop an Integration link highlighted in the Getting started section](/mulesoft/current/en-us/anypoint-code-builder/_images/develop-integration-option-mat.png) 3. Complete the following in the **Develop an Integration** form:
AttributeValue

Project Name

Unique name for your project.

This name is used as the title and name of the integration project file. For example, if the project name is "Salesforce Integration," the project file name is salesforce-integration.

Project Location

Your home directory or another directory you create. Click Browse to select a different directory for the integration project.

Don’t create the project within another project directory.

4. Select the type of project to create by selecting either the **Empty Project** or **Template or Example** card. 5. Select the **Mule runtime** and **Java Version** for your app. 6. Click **Create Project**. ## Adding the Connector to Your Integration Project Anypoint Connectors provide operations for retrieving, modifying, and sending data to and from systems. In addition to the [built-in connectors](https://docs.mulesoft.com/anypoint-code-builder/acb-reference#builtin-connectors) that Anypoint Code Builder provides, you can download many other connectors from Anypoint Exchange. To import a connector from Exchange and add it to your configuration: 1. In the Explorer view, open the configuration XML file for your project, such as `my-project-name.xml`. 2. Click the ![Show Mule graphical mode icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-tree-view.png) (**Show Mule graphical mode**) icon in the activity bar to open the canvas UI if it doesn’t open automatically. 3. Add the connector the same way you added other components from the canvas UI: 1. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 2. In the **Add Component** panel, click **Connectors**. 3. Click the connector name and then click the operation to add, such as **Publish**: ![Add Publish operation from Anypoint MQ Connector](/mulesoft/current/en-us/anypoint-code-builder/_images/int-add-connector-operation.png) If the connector is not available locally, click the ![Search in Exchange icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-search-exchange.png) (**Search in Exchange**) toggle: ![Search in Exchange toggle](/mulesoft/current/en-us/anypoint-code-builder/_images/int-connector-search-exchange.png)
1Search locally
2Search in Exchange
4. Select the connector to add to your project. 5. Select the operation from the **Add Component** panel. Adding a connector to an integration project does not make that connector available to other projects in your Anypoint Code Builder workspace. ## Configuring the Trigger For the Flow A trigger (source) starts the flow when specified conditions are met. If a connector has its own associated sources, you can use a connector-specific trigger to initiate the flow. Each connector trigger has a unique configuration. You can configure the following sources for this connector: - **HTTP > Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met For example, to configure an HTTP Listener trigger, follow these steps: 1. Click the **Listener** component on the canvas UI. 2. (Optional) Click the edit icon to change the name of the **Listener** component. 3. (Optional) If you created a configuration file for the connector, select it. 4. In the **General** tab, in the **Path** field, enter the relative path for the path set in the HTTP configuration element. See [Configure Paths](https://docs.mulesoft.com/http-connector/latest/http-listener-ref#configure-paths). 5. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Allowed methods

To allow all HTTP methods (default), do not define this attribute. To restrict certain methods, specify all allowed HTTP methods, for example, GET, POST, as a comma-separated list.

No

Response streaming mode

Whether to use streaming when the response is sent.

No

Output MIME type

MIME type of the payload that this component outputs.

No

Parameters

Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.

No

Output encoding

Encoding of the payload that this component outputs.

No

Streaming Strategy

Configures the way data streams are consumed in Mule apps.

No

Primary node only

Select this option to execute the Listener trigger on the primary node only when running in a cluster.

No

Redelivery policy

Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.

No

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation.

No

Response

See HTTP Response Attributes.

No

Error Response

HTTP error response returns a status code for the error.

No

Body

Body of the error message.

No

Headers

Headers to include in the error message.

No

Status code

Status code of the error response, for example, 500.

No

Reason phrase

Reason for the error, for example, Gateway Timeout or Internal Server Error.

No

## Configuring a Connector in XML Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Code Builder: - If you manually code a Mule runtime engine (Mule) app in XML from the Anypoint Code Builder XML editor, you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. - If you add the connector in Anypoint Code Builder, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file. This example shows how the namespace statements are placed in the `` XML block: ```xml ``` The Apache Maven `pom.xml` file generated by Anypoint Code Builder contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml {group-id-exchange} {artifact-id-exchange} x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for the connector. 4. Select the connector. 5. Click **Dependency Snippets**. ## Adding Components to Your Project Add components to your integration project to build a flow: 1. In the **Explorer** view, open the XML file for your project, such as `my-project-name.xml`. 2. Select **Build a Flow** from the start card to create an empty flow: ![Anypoint Code Builder canvas with starting cards with the options to start from scratch, build a flow, or build a subflow](/mulesoft/current/en-us/connectors/_images/acb-build-flow.png) 3. Change the name of the flow: 1. Click **Flow**. 2. Click the edit icon. ![Arrow pointing to the flow name edit pencil icon](/mulesoft/current/en-us/connectors/_images/acb-change-flow-name.png) 3. Enter the flow name, and click the checkmark. 4. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 5. In the **Add Component** panel, search for and select your component from the results. The following example shows the **Listener** component from the **HTTP** search results: ![Listener component highlighted in the Add Component section](/mulesoft/current/en-us/anypoint-code-builder/_images/main-tutorial-add-first-listener.png) The configuration XML file now includes the XML for the HTTP Listener into the `` element, for example: ```XML ``` ## Adding a Global Configuration Add another component, this time using the XML configuration menu. For example, add the `` component from a snippet. For more information about snippets, see [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components). 1. In the configuration XML, place your cursor before the `` element and type `http`. Ensure that the cursor is not inside the `` element. 2. Type `http`, and select the `http:listener-config` snippet: ![http:listener-config snippet highlighted in the configuration XML menu](/mulesoft/current/en-us/anypoint-code-builder/_images/add-http-config-snippet.png) The snippet adds the following code: ```xml ``` ## Configuring Authentication for the Connector The Anypoint Connector for HTTP (HTTP Connector) **Request** operation supports connecting a Mule client app to a service that requires any of the following types of authentication: - Basic Authentication - Digest Authentication - NTLM Authentication - OAuth2 Authorization Code Grant Type Authentication ### HTTP XML Authentication Setup Configure HTTP Connector authentication in the XML editor. These are the XML values for HTTP Connector authentication:
Authentication TypeXML Value

Basic Authentication

<http:authentication >
  <http:basic-authentication
  username="UN" password="PW"/>
</http:authentication>

NTLM Authentication

<http:authentication >
  <http:ntlm-authentication
  domain="DM" workstation="WS"
  username="UN" password="PW" />
</http:authentication>

Digest Authentication

<http:authentication >
  <http:digest-authentication
  username="UN" password="PW"/>
</http:authentication>

OAuth 2.0

<http:listener-config name="HTTP_Listener_Configuration"
                      host="0.0.0.0" port="8081" basePath="/github"/>
<http:request-config name="HTTP_Request_Configuration"
                     protocol="HTTPS" host="api.github.com" port="443">
    <http:authentication>
        <oauth:authorization-code-grant-type
        externalCallbackUrl="http://myapp.mycompany.com:8082/callback"
        localAuthorizationUrl="http://localhost:8082/login"
        authorizationUrl="https://github.com/login/oauth/authorize"
        clientId="CLIENT_ID"
        clientSecret="CLIENT_SECRET"
        tokenUrl="https://github.com/login/oauth/access_token" />
    </http:authentication>
</http:request-config>
## Configuring the Component Attributes After you add components to your integration project, configure the attributes in the component UI, or configure the attributes directly in the XML code editor. Connector XML tags start with a namespace followed by an operation, following the syntax `namespace:operation`, such as `` for a **Select** operation in Anypoint Connector for Database (Database Connector). You can use autocomplete from an expression (**fx**) field for a component to select DataWeave functions from the Core module and other values accepted in this field. ### Configuring the HTTP Listener The Anypoint Connector for HTTP (HTTP Connector) **Listener** component enables you to set up an HTTP server and trigger flows when receiving HTTP requests. To configure the HTTP **Listener** attributes in the UI, see [Configuring the Trigger For the Flow](#configuring-http-trigger). ### Configuring the Basic Security Filter The **Basic security filter** component authenticates received HTTP requests. Use this component after a **Listener** component in your integration flow. 1. Click the **Basic security filter** component on the canvas. 2. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Realm

Authentication realm.

Yes

Security Provider

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Basic Security Filter.

No

Attributes

HTTP Request attributes defined in the HTTP Listener source to check the Authorization header.

No

### Configuring the HTTP Request The Anypoint Connector for HTTP (HTTP Connector) **Request** operation enables you to consume an external HTTP service using the default `GET` method. Otherwise, you can choose which methods the operation accepts. To configure the attributes for HTTP **Request** in the Anypoint Code Builder UI: 1. Click the **Request** component on the canvas. 2. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Method

To allow all HTTP methods (default), do not define this attribute. To restrict certain methods, specify all allowed HTTP methods, for example, GET, POST, as a comma-separated list.

No

URI Settings URL

URL to send the request to.

No

URI Settings Path

Path for where to send the request.

No

Request Body

Body of the request response message.

No

Request Headers

Headers to include in the response message.

No

URI Parameters

URI parameters used to create the request.

No

Query Parameters

Query parameters to include in the request.

No

Correlations ID

Defines whether to include an outbound correlation ID in the request.

No

3. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Output MIME type

MIME type of the payload this component outputs.

No

Parameters

Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.

No

Output encoding

Encoding of the payload this component outputs.

No

Streaming Strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Configuring the Streaming Strategy in XML.

No

Follow redirects

Specifies whether or not to follow redirects.

No

Send body mode

Specifies whether the request contains a body. Select Auto to specify that the behavior is determined by the defined allowed HTTP methods (GET, HEAD, and OPTIONS do not send a body).

No

Request streaming mode

Defines whether the request is sent using streaming.

No

Response timeout

Specifies the maximum time in milliseconds that the request element blocks the execution of the flow waiting for the HTTP response.

No

Response validator

Configures default error handling for the request. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Success Status Code Validator and Failure Status Code Validator.

No

Target Variable

Name of the variable on which the operation’s output is placed.

No

Target Value

An expression that’s evaluated against the operation’s output. The outcome of that expression is stored in the target variable.

No

Error Mappings

This attribute is not currently enabled.

No

Reconnection Strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect, Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Load Static Resource The static resource serves static content to use with HTTP. The request path is used to look up the resource. To configure the attributes for HTTP **Load static resource** in the Anypoint Code Builder UI: 1. Click the **Load static resource** component on the canvas. 2. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Resource base path

The base path of the resource that serves up the content, for example, /Users/maxthemule/ resources.

Yes

Default file

The default file to serve when a directory is specified. The default is index.html.

No

Attributes

The HTTP request attributes defined in the HTTP Listener source to check the required resources.

No

3. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Output MIME type

MIME type of the payload this component outputs.

No

Parameters

Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.

No

Output encoding

Encoding of the payload this component outputs.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

This attribute is not currently enabled.

No

## XML Examples ### Configuring the Reconnection Strategy in XML The following is an XML example of a standard reconnection strategy setting the count of reconnection attempts before failing to `5` and setting `failsDeployment` to true, which causes the application deployment to fail if the connection test fails. Because a frequency is not specified, the retry interval is the default of every 2000 ms: ```xml ``` The following is an XML example of a reconnect forever strategy where the connector attempts to reconnect every 4000 ms for as long as the application runs: ```xml ``` ### Configuring the Streaming Strategy in XML You can configure how Mule handles streams with streaming strategies. ### File-Stored Repeatable Stream The following is an XML example of reading a file that is configured with a 1 MB buffer: ```xml ``` If you consistently process a file that’s no larger than 10 KB, you can save memory by reducing the `inMemorySize` attribute: ```xml ``` ### In-Memory Repeatable Stream The following XML example shows an in-memory repeatable stream with a 512 KB initial size, which grows at a rate of 256 KB and allows up to 2000 KB (2 MB) of content in memory: ```xml ``` ## Testing an HTTP Listener Connection To test an HTTP Listener connection, click **Test Connection** in the configuration XML: ![HTTP Listener Test Connection link in the configuration XML](/mulesoft/current/en-us/anypoint-code-builder/_images/http-listener-test-connection.png) The status bar shows the progress: - **Verifying connection inbound-request** indicates that the test is in progress. - **Connection is valid** indicates a successful connection. - **Invalid Connection Got status code: 500 when trying to resolve a Mule Runtime operation** indicates a connection error. A common code `500` error is `port 8081: Address already in use`. For port conflicts, configure a different port, such as `8082`, and retest the connection. Before publishing, run your application in debug mode. ## Creating a New Configuration XML File Anypoint Code Builder creates the initial Mule configuration XML file in `src/main/mule` within the Mule project. This file contains global configurations and flow structures. You can create additional configuration files, for example, to store global configurations. To create a new XML configuration file: 1. In the Explorer view, right-click the **mule** folder (`src/main/mule`) and select **New File**. Alternatively, use the menu. Show me how Select the `mule` folder, and then: - In the desktop IDE, select **File** > **New Mule Configuration File**. - In the cloud IDE, click the ![](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-menu.png) (menu) icon, and select **File** > **New File**. 2. Enter a name for the new file with the `.xml` extension. 3. In the Editor view for the new file, press Ctrl+Space to display available options. 4. Select **Empty mule configuration**: ![New Mule configuration option in auto-correct](/mulesoft/current/en-us/anypoint-code-builder/_images/int-new-mule-config.png) This command adds the following code to the file: ```xml ``` ## See Also - [Anypoint Code Builder Overview](https://docs.mulesoft.com/anypoint-code-builder/) - [Creating Integrations](https://docs.mulesoft.com/anypoint-code-builder/int-create-integrations) - [Using Anypoint Code Builder to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-acb) - [Anypoint Code Builder Components and Commands Reference](https://docs.mulesoft.com/anypoint-code-builder/acb-reference) - [Defining and Securing Properties for a Mule Application](https://docs.mulesoft.com/anypoint-code-builder/int-create-secure-configs) - [Triggering Flows in Your Development Environment](https://docs.mulesoft.com/anypoint-code-builder/int-trigger-flows) - [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components) - [Debugging Mule Applications](https://docs.mulesoft.com/anypoint-code-builder/int-debug-mule-apps) - [Salesforce Help](https://help.salesforce.com) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation) - [Configure Streaming Strategies](https://docs.mulesoft.com/mule-runtime/latest/streaming-about) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Using Anypoint Code Builder to Configure HTTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Cloud IDE (Beta) is scheduled for retirement on August 31, 2026. August 30, 2026 is the last day you can access Cloud IDE (Beta). Download your projects to work from Desktop IDE. Learn more in [Migrate a Project from Cloud IDE to Desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/int-import-mule-project#migrate-cloud-to-desktop). To use Anypoint Code Builder to configure a connector or module, create a basic integration project in Anypoint Code Builder, add connectors and other components to your Mule application to process your business logic, and configure the attributes. ## Before You Begin Before creating an integration project, you must: - [Set up and access the Anypoint Code Builder web or desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/start-acb) - Have credentials to access the connector’s API - Ensure that the Visual Studio Code Extension Pack for Java is installed. To use this connector, you must be familiar with: - The connector’s API - Anypoint Connectors - Mule runtime engine (Mule) ## Creating a New Integration Project To create a new integration project: 1. In the activity bar of the IDE, click the ![Anypoint Code Builder icon](/mulesoft/current/en-us/connectors/_images/acb-icon-ms-logo.png) (**Anypoint Code Builder**) icon. 2. From **Quick Actions**, click **Develop an Integration**: ![Develop an Integration link highlighted in the Getting started section](/mulesoft/current/en-us/anypoint-code-builder/_images/develop-integration-option-mat.png) 3. Complete the following in the **Develop an Integration** form:
AttributeValue

Project Name

Unique name for your project.

This name is used as the title and name of the integration project file. For example, if the project name is "Salesforce Integration," the project file name is salesforce-integration.

Project Location

Your home directory or another directory you create. Click Browse to select a different directory for the integration project.

Don’t create the project within another project directory.

4. Select the type of project to create by selecting either the **Empty Project** or **Template or Example** card. 5. Select the **Mule runtime** and **Java Version** for your app. 6. Click **Create Project**. ## Adding the Connector to Your Integration Project Anypoint Connectors provide operations for retrieving, modifying, and sending data to and from systems. In addition to the [built-in connectors](https://docs.mulesoft.com/anypoint-code-builder/acb-reference#builtin-connectors) that Anypoint Code Builder provides, you can download many other connectors from Anypoint Exchange. To import a connector from Exchange and add it to your configuration: 1. In the Explorer view, open the configuration XML file for your project, such as `my-project-name.xml`. 2. Click the ![Show Mule graphical mode icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-tree-view.png) (**Show Mule graphical mode**) icon in the activity bar to open the canvas UI if it doesn’t open automatically. 3. Add the connector the same way you added other components from the canvas UI: 1. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 2. In the **Add Component** panel, click **Connectors**. 3. Click the connector name and then click the operation to add, such as **Publish**: ![Add Publish operation from Anypoint MQ Connector](/mulesoft/current/en-us/anypoint-code-builder/_images/int-add-connector-operation.png) If the connector is not available locally, click the ![Search in Exchange icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-search-exchange.png) (**Search in Exchange**) toggle: ![Search in Exchange toggle](/mulesoft/current/en-us/anypoint-code-builder/_images/int-connector-search-exchange.png)
1Search locally
2Search in Exchange
4. Select the connector to add to your project. 5. Select the operation from the **Add Component** panel. Adding a connector to an integration project does not make that connector available to other projects in your Anypoint Code Builder workspace. ## Configuring the Trigger For the Flow A trigger (source) starts the flow when specified conditions are met. If a connector has its own associated sources, you can use a connector-specific trigger to initiate the flow. Each connector trigger has a unique configuration. You can configure the following sources for this connector: - **HTTP > Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met For example, to configure an HTTP Listener trigger, follow these steps: 1. Click the **Listener** component on the canvas UI. 2. (Optional) Click the edit icon to change the name of the **Listener** component. 3. (Optional) If you created a configuration file for the connector, select it. 4. In the **General** tab, in the **Path** field, enter the relative path for the path set in the HTTP configuration element. See [Configure Paths](https://docs.mulesoft.com/http-connector/latest/http-listener-ref#configure-paths). 5. Select the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Allowed methods

To allow all HTTP methods (default), do not define this attribute. To restrict certain methods, specify all allowed HTTP methods, for example, GET, POST, as a comma-separated list.

No

Response streaming mode

Whether to use streaming when the response is sent.

No

Output MIME type

MIME type of the payload that this component outputs.

No

Parameters

Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.

No

Output encoding

Encoding of the payload that this component outputs.

No

Streaming Strategy

Configures the way data streams are consumed in Mule apps.

No

Primary node only

Select this option to execute the Listener trigger on the primary node only when running in a cluster.

No

Redelivery policy

Configures the redelivery policy for executing requests that generate errors. You can add a redelivery policy to any source in a flow.

No

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation.

No

Response

See HTTP Response Attributes.

No

Error Response

HTTP error response returns a status code for the error.

No

Body

Body of the error message.

No

Headers

Headers to include in the error message.

No

Status code

Status code of the error response, for example, 500.

No

Reason phrase

Reason for the error, for example, Gateway Timeout or Internal Server Error.

No

## Configuring a Connector in XML Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Code Builder: - If you manually code a Mule runtime engine (Mule) app in XML from the Anypoint Code Builder XML editor, you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. - If you add the connector in Anypoint Code Builder, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file. This example shows how the namespace statements are placed in the `` XML block: ```xml ``` The Apache Maven `pom.xml` file generated by Anypoint Code Builder contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml {group-id-exchange} {artifact-id-exchange} x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for the connector. 4. Select the connector. 5. Click **Dependency Snippets**. ## Adding Components to Your Project Add components to your integration project to build a flow: 1. In the **Explorer** view, open the XML file for your project, such as `my-project-name.xml`. 2. Select **Build a Flow** from the start card to create an empty flow: ![Anypoint Code Builder canvas with starting cards with the options to start from scratch, build a flow, or build a subflow](/mulesoft/current/en-us/connectors/_images/acb-build-flow.png) 3. Change the name of the flow: 1. Click **Flow**. 2. Click the edit icon. ![Arrow pointing to the flow name edit pencil icon](/mulesoft/current/en-us/connectors/_images/acb-change-flow-name.png) 3. Enter the flow name, and click the checkmark. 4. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 5. In the **Add Component** panel, search for and select your component from the results. The following example shows the **Listener** component from the **HTTP** search results: ![Listener component highlighted in the Add Component section](/mulesoft/current/en-us/anypoint-code-builder/_images/main-tutorial-add-first-listener.png) The configuration XML file now includes the XML for the HTTP Listener into the `` element, for example: ```XML ``` ## Adding a Global Configuration Add another component, this time using the XML configuration menu. For example, add the `` component from a snippet. For more information about snippets, see [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components). 1. In the configuration XML, place your cursor before the `` element and type `http`. Ensure that the cursor is not inside the `` element. 2. Type `http`, and select the `http:listener-config` snippet: ![http:listener-config snippet highlighted in the configuration XML menu](/mulesoft/current/en-us/anypoint-code-builder/_images/add-http-config-snippet.png) The snippet adds the following code: ```xml ``` ## Configuring Authentication for the Connector The Anypoint Connector for HTTP (HTTP Connector) **Request** operation supports connecting a Mule client app to a service that requires any of the following types of authentication: - Basic Authentication - Digest Authentication - NTLM Authentication - OAuth2 Authorization Code Grant Type Authentication ### HTTP XML Authentication Setup Configure HTTP Connector authentication in the XML editor. These are the XML values for HTTP Connector authentication:
Authentication TypeXML Value

Basic Authentication

<http:authentication >
  <http:basic-authentication
  username="UN" password="PW"/>
</http:authentication>

NTLM Authentication

<http:authentication >
  <http:ntlm-authentication
  domain="DM" workstation="WS"
  username="UN" password="PW" />
</http:authentication>

Digest Authentication

<http:authentication >
  <http:digest-authentication
  username="UN" password="PW"/>
</http:authentication>

OAuth 2.0

<http:listener-config name="HTTP_Listener_Configuration"
                      host="0.0.0.0" port="8081" basePath="/github"/>
<http:request-config name="HTTP_Request_Configuration"
                     protocol="HTTPS" host="api.github.com" port="443">
    <http:authentication>
        <oauth:authorization-code-grant-type
        externalCallbackUrl="http://myapp.mycompany.com:8082/callback"
        localAuthorizationUrl="http://localhost:8082/login"
        authorizationUrl="https://github.com/login/oauth/authorize"
        clientId="CLIENT_ID"
        clientSecret="CLIENT_SECRET"
        tokenUrl="https://github.com/login/oauth/access_token" />
    </http:authentication>
</http:request-config>
## Configuring the Component Attributes After you add components to your integration project, configure the attributes in the component UI, or configure the attributes directly in the XML code editor. Connector XML tags start with a namespace followed by an operation, following the syntax `namespace:operation`, such as `` for a **Select** operation in Anypoint Connector for Database (Database Connector). You can use autocomplete from an expression (**fx**) field for a component to select DataWeave functions from the Core module and other values accepted in this field. ### Configuring the HTTP Listener The Anypoint Connector for HTTP (HTTP Connector) **Listener** component enables you to set up an HTTP server and trigger flows when receiving HTTP requests. To configure the HTTP **Listener** attributes in the UI, see [Configuring the Trigger For the Flow](#configuring-http-trigger). ### Configuring the Basic Security Filter The **Basic security filter** component authenticates received HTTP requests. Use this component after a **Listener** component in your integration flow. 1. Click the **Basic security filter** component on the canvas. 2. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Realm

Authentication realm.

Yes

Security Provider

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Basic Security Filter.

No

Attributes

HTTP Request attributes defined in the HTTP Listener source to check the Authorization header.

No

### Configuring the HTTP Request The Anypoint Connector for HTTP (HTTP Connector) **Request** operation enables you to consume an external HTTP service using the default `GET` method. Otherwise, you can choose which methods the operation accepts. To configure the attributes for HTTP **Request** in the Anypoint Code Builder UI: 1. Click the **Request** component on the canvas. 2. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Method

To allow all HTTP methods (default), do not define this attribute. To restrict certain methods, specify all allowed HTTP methods, for example, GET, POST, as a comma-separated list.

No

URI Settings URL

URL to send the request to.

No

URI Settings Path

Path for where to send the request.

No

Request Body

Body of the request response message.

No

Request Headers

Headers to include in the response message.

No

URI Parameters

URI parameters used to create the request.

No

Query Parameters

Query parameters to include in the request.

No

Correlations ID

Defines whether to include an outbound correlation ID in the request.

No

3. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Output MIME type

MIME type of the payload this component outputs.

No

Parameters

Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.

No

Output encoding

Encoding of the payload this component outputs.

No

Streaming Strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Configuring the Streaming Strategy in XML.

No

Follow redirects

Specifies whether or not to follow redirects.

No

Send body mode

Specifies whether the request contains a body. Select Auto to specify that the behavior is determined by the defined allowed HTTP methods (GET, HEAD, and OPTIONS do not send a body).

No

Request streaming mode

Defines whether the request is sent using streaming.

No

Response timeout

Specifies the maximum time in milliseconds that the request element blocks the execution of the flow waiting for the HTTP response.

No

Response validator

Configures default error handling for the request. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Success Status Code Validator and Failure Status Code Validator.

No

Target Variable

Name of the variable on which the operation’s output is placed.

No

Target Value

An expression that’s evaluated against the operation’s output. The outcome of that expression is stored in the target variable.

No

Error Mappings

This attribute is not currently enabled.

No

Reconnection Strategy

This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect, Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Load Static Resource The static resource serves static content to use with HTTP. The request path is used to look up the resource. To configure the attributes for HTTP **Load static resource** in the Anypoint Code Builder UI: 1. Click the **Load static resource** component on the canvas. 2. In the **General** tab, configure the following attributes:
UI FieldDescriptionRequired

Resource base path

The base path of the resource that serves up the content, for example, /Users/maxthemule/ resources.

Yes

Default file

The default file to serve when a directory is specified. The default is index.html.

No

Attributes

The HTTP request attributes defined in the HTTP Listener source to check the required resources.

No

3. Select the **Advanced** tab to configure the following attributes:
UI FieldDescriptionRequired

Output MIME type

MIME type of the payload this component outputs.

No

Parameters

Appends a key-value pair for a reader property to the value of the Output MIME attribute. Multiple key-value pairs are allowed.

No

Output encoding

Encoding of the payload this component outputs.

No

Target Variable

Name of the variable that stores the operation’s output.

No

Target Value

Expression that evaluates the operation’s output. The expression outcome is stored in the target variable.

No

Error Mappings

This attribute is not currently enabled.

No

## XML Examples ### Configuring the Reconnection Strategy in XML The following is an XML example of a standard reconnection strategy setting the count of reconnection attempts before failing to `5` and setting `failsDeployment` to true, which causes the application deployment to fail if the connection test fails. Because a frequency is not specified, the retry interval is the default of every 2000 ms: ```xml ``` The following is an XML example of a reconnect forever strategy where the connector attempts to reconnect every 4000 ms for as long as the application runs: ```xml ``` ### Configuring the Streaming Strategy in XML You can configure how Mule handles streams with streaming strategies. ### File-Stored Repeatable Stream The following is an XML example of reading a file that is configured with a 1 MB buffer: ```xml ``` If you consistently process a file that’s no larger than 10 KB, you can save memory by reducing the `inMemorySize` attribute: ```xml ``` ### In-Memory Repeatable Stream The following XML example shows an in-memory repeatable stream with a 512 KB initial size, which grows at a rate of 256 KB and allows up to 2000 KB (2 MB) of content in memory: ```xml ``` ## Testing an HTTP Listener Connection To test an HTTP Listener connection, click **Test Connection** in the configuration XML: ![HTTP Listener Test Connection link in the configuration XML](/mulesoft/current/en-us/anypoint-code-builder/_images/http-listener-test-connection.png) The status bar shows the progress: - **Verifying connection inbound-request** indicates that the test is in progress. - **Connection is valid** indicates a successful connection. - **Invalid Connection Got status code: 500 when trying to resolve a Mule Runtime operation** indicates a connection error. A common code `500` error is `port 8081: Address already in use`. For port conflicts, configure a different port, such as `8082`, and retest the connection. Before publishing, run your application in debug mode. ## Creating a New Configuration XML File Anypoint Code Builder creates the initial Mule configuration XML file in `src/main/mule` within the Mule project. This file contains global configurations and flow structures. You can create additional configuration files, for example, to store global configurations. To create a new XML configuration file: 1. In the Explorer view, right-click the **mule** folder (`src/main/mule`) and select **New File**. Alternatively, use the menu. Show me how Select the `mule` folder, and then: - In the desktop IDE, select **File** > **New Mule Configuration File**. - In the cloud IDE, click the ![](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-menu.png) (menu) icon, and select **File** > **New File**. 2. Enter a name for the new file with the `.xml` extension. 3. In the Editor view for the new file, press Ctrl+Space to display available options. 4. Select **Empty mule configuration**: ![New Mule configuration option in auto-correct](/mulesoft/current/en-us/anypoint-code-builder/_images/int-new-mule-config.png) This command adds the following code to the file: ```xml ``` ## See Also - [Anypoint Code Builder Overview](https://docs.mulesoft.com/anypoint-code-builder/) - [Creating Integrations](https://docs.mulesoft.com/anypoint-code-builder/int-create-integrations) - [Using Anypoint Code Builder to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-acb) - [Anypoint Code Builder Components and Commands Reference](https://docs.mulesoft.com/anypoint-code-builder/acb-reference) - [Defining and Securing Properties for a Mule Application](https://docs.mulesoft.com/anypoint-code-builder/int-create-secure-configs) - [Triggering Flows in Your Development Environment](https://docs.mulesoft.com/anypoint-code-builder/int-trigger-flows) - [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components) - [Debugging Mule Applications](https://docs.mulesoft.com/anypoint-code-builder/int-debug-mule-apps) - [Salesforce Help](https://help.salesforce.com) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation) - [Configure Streaming Strategies](https://docs.mulesoft.com/mule-runtime/latest/streaming-about) --- product: HTTP Connector version: 1.10 --- # Using Anypoint Studio to Configure HTTP Connector 1.10 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files. To add and configure a connector in Studio: 1. [Create a Mule project](#create-mule-project). 2. [Add the connector to your Mule project](#add-connector-to-project). 3. [Configure a source for the connector’s flow](#configure-source). 4. [Add a connector operation to the flow](#add-connector-operation). 5. [Configure a global element for the connector](#configure-global-element). When you run the connector, you can view the app log to check for problems in real time, as described in [View the App Log](#view-app-log). If you are new to configuring connectors in Studio, see [Use Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio). If, after reading this topic, you need additional information about the connector fields, see the [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation). ## Create a Mule Project In Studio, create a new Mule project in which to add and configure the connector: 1. In Studio, select **File > New > Mule Project**. 2. Enter a name for your Mule project and click **Finish**. ## Add the Connector to Your Mule Project Add HTTP Connector to your Mule project to automatically populate the XML code with the connector’s namespace and schema location and add the required dependencies to the project’s `pom.xml` file: 1. In **Mule Palette**, click **(X) Search in Exchange**. 2. In **Add Dependencies to Project**, type `http` in the search field. 3. Click **HTTP** in **Available modules**. 4. Click **Add**. 5. Click **Finish**. Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace. ## Configure a Source A source initiates a flow when a specified condition is met. You can configure one of these sources to use with HTTP Connector: - HTTP **Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met For example, to configure an HTTP **Listener** source, follow these steps: 1. In **Mule Palette**, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 4. Specify a value for the **Path** field. 5. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP Listener source in the app. 6. On the **General** tab, specify connection information for the connector. 7. On the **TLS** tab, optionally specify the TLS information for the connector. 8. On the **Advanced** tab, optionally specify reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect with the specified server. 10. Click **OK**. ## Add a Connector Operation to the Flow When you add a connector operation to your flow, you are specifying an action for that connector to perform. To add an operation for HTTP Connector, follow these steps: 1. In **Mule Palette**, select **HTTP** and then select the desired operation. 2. Drag the operation onto the Studio canvas, next to the input source. ![Studio Mule palette with HTTP Connector operations](/mulesoft/current/en-us/http-connector/1.10/_images/http-connector-operations.png) You can configure one of these operations to use with HTTP Connector: - **Basic security filter** Secures and authenticates requests to your service. - **Load a static resource** Brings a resource, such as a script, from the file system into your Mule app to be returned by an HTTP **Listener** source. - **Request** Consumes an HTTP service. ## Configure a Global Element for the Connector When you configure a connector, configure a global element that all instances of that connector in the app can use. For example, to configure the global element for the HTTP **Listener** source, follow these steps: 1. Select the source in the Studio canvas. 2. In the **General** configuration screen for the operation, click the **Add** icon (![2%](/mulesoft/current/en-us/http-connector/1.10/_images/add-16x16.png)) to access the global element configuration fields. 3. In the **General** tab, set the following fields: - **Protocol**: `HTTP (Default)` or `HTTPS` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 4. In the **TLS** tab, optionally specify the TLS information for the connector. 5. In the **Advanced** tab, optionally specify reconnection information, including a reconnection strategy. 6. Click **Test Connection** to confirm that Mule can connect with the specified server. 7. Click **OK**. ![HTTP Listener global configuration window with Host field set to 0.0.0.0 and Port field to 8081](/mulesoft/current/en-us/http-connector/1.10/_images/http-listener-global-element.png) ## View the App Log To check for problems, you can view the app log as follows: - If you’re running the app from Anypoint Platform, the app log output goes to the Anypoint Studio console window. - If you’re running the app using Mule from the command line, the app log output goes to your operating system console. Unless the log file path is customized in the app’s log file (`log4j2.xml`), you can also access the app log in the default location `MULE_HOME/logs/.log`. You can configure the location of the log path in the app log file `log4j2.xml`. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.10/http-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.11 --- # Using Anypoint Studio to Configure HTTP Connector 1.11 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files. To add and configure a connector in Studio: 1. [Create a Mule project](#create-mule-project). 2. [Add the connector to your Mule project](#add-connector-to-project). 3. [Configure a source for the connector’s flow](#configure-source). 4. [Add a connector operation to the flow](#add-connector-operation). 5. [Configure a global element for the connector](#configure-global-element). When you run the connector, you can view the app log to check for problems in real time, as described in [View the App Log](#view-app-log). If you are new to configuring connectors in Studio, see [Use Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio). If, after reading this topic, you need additional information about the connector fields, see the [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation). ## Create a Mule Project In Studio, create a new Mule project in which to add and configure the connector: 1. In Studio, select **File > New > Mule Project**. 2. Enter a name for your Mule project and click **Finish**. ## Add the Connector to Your Mule Project Add HTTP Connector to your Mule project to automatically populate the XML code with the connector’s namespace and schema location and add the required dependencies to the project’s `pom.xml` file: 1. In **Mule Palette**, click **(X) Search in Exchange**. 2. In **Add Dependencies to Project**, type `http` in the search field. 3. Click **HTTP** in **Available modules**. 4. Click **Add**. 5. Click **Finish**. Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace. ## Configure a Source A source initiates a flow when a specified condition is met. You can configure one of these sources to use with HTTP Connector: - HTTP **Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met For example, to configure an HTTP **Listener** source, follow these steps: 1. In **Mule Palette**, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 4. Specify a value for the **Path** field. 5. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP Listener source in the app. 6. On the **General** tab, specify connection information for the connector. 7. On the **TLS** tab, optionally specify the TLS information for the connector. 8. On the **Advanced** tab, optionally specify reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect with the specified server. 10. Click **OK**. ## Add a Connector Operation to the Flow When you add a connector operation to your flow, you are specifying an action for that connector to perform. To add an operation for HTTP Connector, follow these steps: 1. In **Mule Palette**, select **HTTP** and then select the desired operation. 2. Drag the operation onto the Studio canvas, next to the input source. ![Studio Mule palette with HTTP Connector operations](/mulesoft/current/en-us/http-connector/1.11/_images/http-connector-operations.png) You can configure one of these operations to use with HTTP Connector: - **Basic security filter** Secures and authenticates requests to your service. - **Load a static resource** Brings a resource, such as a script, from the file system into your Mule app to be returned by an HTTP **Listener** source. - **Request** Consumes an HTTP service. ## Configure a Global Element for the Connector When you configure a connector, configure a global element that all instances of that connector in the app can use. For example, to configure the global element for the HTTP **Listener** source, follow these steps: 1. Select the source in the Studio canvas. 2. In the **General** configuration screen for the operation, click the **Add** icon (![2%](/mulesoft/current/en-us/http-connector/1.11/_images/add-16x16.png)) to access the global element configuration fields. 3. In the **General** tab, set the following fields: - **Protocol**: `HTTP (Default)` or `HTTPS` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 4. In the **TLS** tab, optionally specify the TLS information for the connector. 5. In the **Advanced** tab, optionally specify reconnection information, including a reconnection strategy. 6. Click **Test Connection** to confirm that Mule can connect with the specified server. 7. Click **OK**. ![HTTP Listener global configuration window with Host field set to 0.0.0.0 and Port field to 8081](/mulesoft/current/en-us/http-connector/1.11/_images/http-listener-global-element.png) ## View the App Log To check for problems, you can view the app log as follows: - If you’re running the app from Anypoint Platform, the app log output goes to the Anypoint Studio console window. - If you’re running the app using Mule from the command line, the app log output goes to your operating system console. Unless the log file path is customized in the app’s log file (`log4j2.xml`), you can also access the app log in the default location `MULE_HOME/logs/.log`. You can configure the location of the log path in the app log file `log4j2.xml`. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/1.11/http-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: HTTP Connector version: 1.12 is-latest-version: true --- # Using Anypoint Studio to Configure HTTP Connector 1.12 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files. To add and configure a connector in Studio: 1. [Create a Mule project](#create-mule-project). 2. [Add the connector to your Mule project](#add-connector-to-project). 3. [Configure a source for the connector’s flow](#configure-source). 4. [Add a connector operation to the flow](#add-connector-operation). 5. [Configure a global element for the connector](#configure-global-element). When you run the connector, you can view the app log to check for problems in real time, as described in [View the App Log](#view-app-log). If you are new to configuring connectors in Studio, see [Use Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio). If, after reading this topic, you need additional information about the connector fields, see the [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation). ## Create a Mule Project In Studio, create a new Mule project in which to add and configure the connector: 1. In Studio, select **File > New > Mule Project**. 2. Enter a name for your Mule project and click **Finish**. ## Add the Connector to Your Mule Project Add HTTP Connector to your Mule project to automatically populate the XML code with the connector’s namespace and schema location and add the required dependencies to the project’s `pom.xml` file: 1. In **Mule Palette**, click **(X) Search in Exchange**. 2. In **Add Dependencies to Project**, type `http` in the search field. 3. Click **HTTP** in **Available modules**. 4. Click **Add**. 5. Click **Finish**. Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace. ## Configure a Source A source initiates a flow when a specified condition is met. You can configure one of these sources to use with HTTP Connector: - HTTP **Listener** Initiates a flow each time it receives a request on the configured host and port - **Scheduler** Initiates a flow when a time-based condition is met For example, to configure an HTTP **Listener** source, follow these steps: 1. In **Mule Palette**, select **HTTP > Listener**. 2. Drag **Listener** to the Studio canvas. 3. On the **Listener** configuration screen, optionally change the value of the **Display Name** field. 4. Specify a value for the **Path** field. 5. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP Listener source in the app. 6. On the **General** tab, specify connection information for the connector. 7. On the **TLS** tab, optionally specify the TLS information for the connector. 8. On the **Advanced** tab, optionally specify reconnection information, including a reconnection strategy. 9. Click **Test Connection** to confirm that Mule can connect with the specified server. 10. Click **OK**. ## Add a Connector Operation to the Flow When you add a connector operation to your flow, you are specifying an action for that connector to perform. To add an operation for HTTP Connector, follow these steps: 1. In **Mule Palette**, select **HTTP** and then select the desired operation. 2. Drag the operation onto the Studio canvas, next to the input source. ![Studio Mule palette with HTTP Connector operations](/mulesoft/current/en-us/http-connector/latest/_images/http-connector-operations.png) You can configure one of these operations to use with HTTP Connector: - **Basic security filter** Secures and authenticates requests to your service. - **Load a static resource** Brings a resource, such as a script, from the file system into your Mule app to be returned by an HTTP **Listener** source. - **Request** Consumes an HTTP service. ## Configure a Global Element for the Connector When you configure a connector, configure a global element that all instances of that connector in the app can use. For example, to configure the global element for the HTTP **Listener** source, follow these steps: 1. Select the source in the Studio canvas. 2. In the **General** configuration screen for the operation, click the **Add** icon (![2%](/mulesoft/current/en-us/http-connector/latest/_images/add-16x16.png)) to access the global element configuration fields. 3. In the **General** tab, set the following fields: - **Protocol**: `HTTP (Default)` or `HTTPS` - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 4. In the **TLS** tab, optionally specify the TLS information for the connector. 5. In the **Advanced** tab, optionally specify reconnection information, including a reconnection strategy. 6. Click **Test Connection** to confirm that Mule can connect with the specified server. 7. Click **OK**. ![HTTP Listener global configuration window with Host field set to 0.0.0.0 and Port field to 8081](/mulesoft/current/en-us/http-connector/latest/_images/http-listener-global-element.png) ## View the App Log To check for problems, you can view the app log as follows: - If you’re running the app from Anypoint Platform, the app log output goes to the Anypoint Studio console window. - If you’re running the app using Mule from the command line, the app log output goes to your operating system console. Unless the log file path is customized in the app’s log file (`log4j2.xml`), you can also access the app log in the default location `MULE_HOME/logs/.log`. You can configure the location of the log path in the app log file `log4j2.xml`. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio) - [HTTP Connector Reference](https://docs.mulesoft.com/http-connector/latest/http-documentation) - [Salesforce Help](https://help.salesforce.com)