Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

To Consume a REST Service (Design Center)

You can design an app to consume a REST service by setting up HTTP Listener and Request operations. In this procedure, you first consume a REST API service. Next, you test the HTTP request. You edit the Request configuration to make a secure HTTPS request. Finally, you test the HTTPS Request.

  1. In a new project, set up the HTTP Listener for a message from the browser to start this app: Use the default CloudHub HTTP configuration and set Path to /trigger.

  2. Click + to add another component to the flow, and select HTTP Request.

  3. In HTTP Request, in General, set Path Or URL to http://jsonplaceholder.typicode.com/users. In Advanced, set Allowed Methods to GET. Accept the other default settings and close the configuration.

  4. Click Deploy, and the execute the flow:

    • Click Copy Link.

    • Paste the link in a browser or client, and type /trigger at the end.

      The HTTP Listener hears the request, and starts the app. The list of JSON Placeholder users appears in the browser.

  5. Open HTTP - Request, and click Output.

    The list of users appears in Payload, and in Payload > Attributes, the attributes you can use in DataWeave expressions appear.

  6. Click Configuration > Edit, and configure the following options:

    • In HTTP Configuration, in Protocol, select HTTPS.

    • In Port, enter 443

    • Save.

  7. In HTTP Request, change Path Or URL as follows:

    • FROM: http://jsonplaceholder.typicode.com/users

    • TO: https://jsonplaceholder.typicode.com/users

  8. Click Deploy. Fire the app trigger:

    • Select Copy Link.

    • Paste the link in a browser or client, and type /trigger at the end.

      The list of users appears in Payload, and in Payload > Attributes, the attributes you can use in DataWeave expressions appear.

In this topic: