Contact Free trial Login

Anypoint Exchange

Home to the complete listing of connectors, templates, examples and APIs.
Discover and use proven assets built by the MuleSoft ecosystem, or add assets to a private
tenant of Anypoint Exchange for collaboration and sharing of internal best practices.

Exposing a RESTful resource using the HTTP connector

Exposing a RESTful resource using the HTTP connector

(0 reviews)

Illustrates how to use Mule to expose a RESTful resource using the HTTP connector. After reading this document, creating, and running the example in Mule, you should be able to leverage what you have learned to create a simple HTTP request-response application that is able to expose a RESTful resource by providing different verbs (HTTP methods) using JSON data.


In this example, a user calls the Mule application by submitting a request via a REST client (that is, entering a specific URL, such as http://localhost:8081/person/1). The application receives the request and processes it based on the URL. The application is capable of retrieving and inserting the person's data.

Set Up and Run the Example

As with other examples, you can create template applications straight out of the box in Anypoint Studio. You can tweak the configurations of these use case-based examples to create your own customized applications in Mule.

Follow the procedure below to create, then run the HTTP with JSON application.

  1. Create, then run the example application in Anypoint Studio or Standalone.
  2. Send a POST request to http://localhost:8081/person with the body equals to:

          "age": "12",
             "streetAddress":"Lincoln St.",
             "city":"San Francisco",
  3. You should recieve a response saying a person was created successfully:

     { "status": "success", "statusDescription": "person created successfully"}
  4. Send a GET request to http://localhost:8081/person/1
  5. You should recieve a response with the person data:

     {"firstname":"John","lastname":"Doe","address":{"streetAddress":"Lincoln St.","city":"San Francisco","state":"CA","zipCode":"90401"},"age":12}
  6. Send a GET request to http://localhost:8081/person

  7. You should recieve a response with all created persons. If you inserted only 1 person from Step 2, then you should get only that one.


Read full documentation in GitHub


Log into Anypoint Platform to download this asset


Created by
MuleSoft Organization
Published onJun 22, 2017


VersionRuntime version
Show more