Send an HTTP Request

Create a pipeline step that invokes an HTTP request.

This tutorial will walk you through adding a HTTP Request step in a Sophos Factory pipeline. The HTTP Request step module can be used to send HTTP requests to any external web-based API server.

This tutorial assumes you already have:

  • A Sophos Factory account
  • A Sophos Factory project
  • An Existing pipeline

Step 1: Add a HTTP Step into the Builder

Navigate to your pipeline and click “Open in Builder”. Find the HTTP Request step module from the step module list in the left pane. Click and drag into the builder to add an instance of a HTTP Request step.

Step 2: Create Variables in your Pipeline

Add a variable for the URL that will be the recipient of the request. For this tutorial, we will be sending the request to https://httpbin.org , which is a free HTTP request testing service.

Click on the “Variables” tab at the top right of the builder and click the Add Variable button.

Enter the following values in the corresponding fields:

Optionally add a description. Then click “Submit”.

Next, add a variable for the method to be used when making the request. Click the “Add Variable” button again. Enter the following values in the corresponding fields:

  • Variable Type: String
  • Name: Method
  • Key: method
  • Value: GET

Optionally add a description. Then click “Submit”.

Step 3: Add a Pipeline Output

Add an output that will return the public IPAddress of the runner. Back on the Variables form, click on the “Add Output” button. Enter the following values in the corresponding fields:

  • Key: Origin
  • Value: findStepById('http1').result.body.origin

Then click Save.

For more information about Pipeline Variables, read Running Pipelines.

findStepById() is a Pipeline Helper Function. For more information about outputs, visit Pipeline Helper Functions

Step 4: Configure the HTTP Request Step

Click on the HTTP Request step in the builder and the step properties form will appear on the right. Update the fields with the following values:

  • URL: vars.url
  • Method: vars.method

Be sure to toggle each of them to Evaluation Mode first because we are using variables for values! When you are finished, click Save at the top of the step form. Then, click Save at the top left of the builder (a Save Pipeline dialog will appear. Enter some revision notes, and then click Save.)

Step 5: Run the Pipeline

Click the “Run” button at the top left. A Run Pipeline dialog will appear displaying the pre-populated values for the variables. Proceed to click the “Run” button.

Step 6: Monitor Run Progress

After clicking “Run”, you are brought to the current run in progress. Here you can see the console output of the selected run. If the run was successful, you should see a green check mark on the HTTP Request step on the left side, and some positive console output as shown in the image below. You can also view the value for the output property origin by clicking on the triple-dot menu and choosing Outputs from the list.