Skip to main content

Timed Http Request

Introduction#

In this lesson we will be using the HTTP component and see what it can do. If you have followed this tutorial series you will already be familiar with how we can create our own APIs using Jetic and also how to test them using Postman. You will see how we can use the HTTP component to pull in data from an external HTTP endpoint.

VisionsCorp’s request#

VisionsCorp (VC) needs to pull in data from an external system. They heard that Jetic contains an out of the box component 'HTTP' that can help with this task. They have assigned you to create a very simple integration in order to test this component. They have given you a sample URL to use as the test for the component.

  • Timer
  • Remove Headers
  • Http
  • Log

Step 1: Adding a Timer#

Docusaurus

  • Add a Timer component to the route lane and add a period of 60000 with a delay of 1000
  • Under the Timer add a Remove Headers component
  • For the pattern add * and an EXCLUDE PATTERN as Camel*

Step 2: Using HTTP#

Docusaurus

  • Add a Http component to the route lane under the Remove Headers component
  • For the HTTP PROTOCOL declare https
  • For the HTTP METHOD choose GET
  • For the CONNECTION REQUEST TIMEOUT,CONNECTION TIMEOUT, AND SOCKET TIMEOUT make sure they are all set to 20000
  • For the HTTP URI put jsonplaceholder.typicode.com/todos/1

Step 3: Making a Callout#

Docusaurus

  • After the Http Component add a Log
  • For the Log MESSAGE New todo:\n${body}
  • Run the integration and look at the output
  • When it boots you should see something like
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}

🎉 Congratulations you have successfully made a call to an external HTTP endpoint. You may already start to see how this could be useful. This was a small example of how you can receive requests from other services and then display or even manipulate the data. Now that VisionsCorp knows what is available using this component they can further iterate on their knowledge and with your help, start to create even more complex integrations.🎉