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.
-
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.
-
Click + to add another component to the flow, and select HTTP Request.
-
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. -
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.
-
-
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.
-
Click Configuration > Edit, and configure the following options:
-
In HTTP Configuration, in Protocol, select HTTPS.
-
In Port, enter 443
-
Save.
-
-
In HTTP Request, change Path Or URL as follows:
-
FROM:
http://jsonplaceholder.typicode.com/users
-
TO:
https://jsonplaceholder.typicode.com/users
-
-
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.
-