---
schema_version: "1"
id: 26a6b4ef2569e9155b8d9cf2123beece6449340775b00f8f26ba1cf5c961d07d
title: HTTP Connector 1.11
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/http-connector/1.11/index.md
canonical_url: https://docs.mulesoft.com/http-connector/1.11/
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 211b314ab8033cc8949357550f49fc3634da95e0249d0aca6418c053c74f854c
description: MuleSoft Documentation Site
release: "1.11"
latest: false
---
---
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
<http:listener-config name="serverConfig">
  <http:listener-connection host="localhost" port="8081"/>
</http:listener-config>
```

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
<flow name="hello">
    <http:listener path="greet" config-ref="serverConfig"/>
    <set-payload value="Hello, world!"/>
</flow>

<flow name="bye">
    <http:listener path="exit" config-ref="serverConfig"/>
    <set-payload value="Goodbye, world!"/>
</flow>
```

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
<flow name="hello">
  <http:listener path="greet" config-ref="serverConfig">
    <http:response>
      <http:body>
        #[payload ++ ' I am an HTTP server.']
      </http:body>
    </http:response>
  </http:listener>
  <set-payload value="#['Hello, ' ++ (attributes.queryParams.name default 'world') ++ '!']" />
</flow>
```

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
<http:request-config name="clientConfig">
  <http:request-connection host="localhost" port="8081"/>
</http:request-config>
```

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
<flow name="helloAndBye">
  <http:request method="GET" path="greet" config-ref="clientConfig"/>
  <logger level="INFO" message="#[payload]"/>
  <http:request method="GET" path="exit" config-ref="clientConfig"/>
  <logger level="INFO" message="#[payload]"/>
</flow>
```

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
<flow name="fullHello">
  <http:request method="GET" path="greet" config-ref="clientConfig">
    <http:query-params>
      #[{"name" : "HTTP client"}]
    </http:query-params>
  </http:request>
  <logger level="INFO"
   message="#['Received a ' ++ attributes.statusCode ++ ' response with body: {' ++ payload ++ '}']"/>
</flow>
```

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)
