Jump to a Section
  • Introduction

    This walk-through demonstrates how to call a sample API endpoint in an unauthenticated form using the Workflows HTTP Raw Request card. Amazon hosts a free, publicly available REST API sample endpoint called Amazon PetStore API. It can be invoked from a browser or a REST client like POSTMAN. The response is a JSON payload with data of a page of available pets in the PetStore.

    This Flow will set “Content-Type” and “Accept” HTTP headers and will pass in two query parameters. The output will match the payload in the browser or POSTMAN.

    There are multiple tasks in this tutorial:

    • Create the raw request
    • Build a child Flow
    • Test the Flow
    • Create the outputs

    Prerequisites

    The returned payload contains three pets (id #4,#5,#6) in a JSON array format. Each pet has an id, type, and price attribute.

    Tip: Use the Note function to copy your parameters into a scratch pad. From here, you can copy and paste the HTTP contents into the card without switching between views.

  • Create a connection setting

    1. In Admin Console, go to Workflow > Workflows Console.
    2. At the top navigation bar, select Settings.
    3. Under Connections, click New Connection.
    4. Select HTTP.
    5. In the Connection Nickname field, enter HTTP PetStore.
    6. For Auth Type, select None.
    7. To save the connection, click Create.
  • Create a raw request

    1. In Admin Console, go to Workflow > Workflows Console.
    2. In Workflows console, click New Flow.
    3. Click Function, and then select HTTP.
    4. Choose Raw Request from the HTTP menu.
    5. In the HTTP Raw Request card, choose the HTTP PetStore connection that you just created and enter the URL (API endpoint without the query parameters): http://petstore-demo-endpoint.execute-api.com/petstore/pets.
    6. Enter the method as GET.
    7. Copy the headers into the HTTP Raw Request card as shown below (Note: entered as an Object):

      {
      "Accept": "application/json",
      "Content-Type": "application/json"
      }
    8. Copy the query parameters into the HTTP Raw Request card as shown below (Note: entered as an Object):

      {
      "type": "Dog",
      "page": "2"
      }
    9. Name and save the Flow, and then test the card in isolation.

    10. Verify that the response headers and body are correct.

  • Populate values dynamically into Raw Request card

    Creating a child flow enables you to set parameters and test the flow in isolation.

    1. In the same Flow, click Add Event, and then select Child Flow.
    2. In the Inputs to this Flow field, enter the following: * key1 * value1 * key2 * value2
    3. For the parameters, enter the key value pairs.
    4. Click Add Another > Function > If/Else. (A branching function makes it easy to exclude cards in a Flow).
    5. In the Branching card, set your condition to 1=1, and then click Done.
    6. Drag and drop your HTTP Raw Request card to the Run when FALSE portion.
    7. In the Run when TRUE portion, click Add Another > Function > Assign.
    8. In the Assign card, create the following fields and values:
      • Method = GET
      • Accept = application/json
      • Content-Type = application/json
    9. In the Run when TRUE portion, click Add Another > Function > Object > Construct.
    10. In the Construct card, create the following fields, and drag the contents from the Assign card.
      • Content-Type
      • Accept
    11. In the Run when TRUE portion, click Add Another > Function > Object > Set.
    12. Drag and drop the key1 and value1 from the Child Flow card to the Set card.
    13. In the Run when TRUE portion, click Add Another > Function > Object > Set.
    14. Drag and drop the key2 and value2 from the Child Flow card to the second Set card.
    15. In the Run when TRUE portion, click Add Another > Function > Object > Merge.
    16. Drag and drop the outputs from your Set cards to the object 1 and object 2 fields of the Merge card.
    17. In the Run when TRUE portion, click Add Another > Function > HTTP > Raw Request.
      • Drag and drop the Merge output field to the Raw Request query field.
      • Drag and drop the Construct output field to the Raw Request headers field.
      • Drag and drop the Child Flow url field to the Raw Request url field.
      • As a best practice, consider naming the output fields that you dragged query and headers.
    18. Save your Flow, and then toggle the Flow is OFF switch to ON.
  • Test the Flow

    1. Copy the input, and then click Test.
    2. In the Test window, paste the following values:
    3. Click Test.
    4. In the executed Flow, scroll to the HTTP Raw Request card and check the details of the body field. Verify that the contents match your Postman statement.
  • Create the output

    1. In your If/Else card, click Create outputs.
    2. Name your first output field statusCode and your second field body.
    3. Drag and drop the HTTP Raw Request statusCode field (the card in the Run When TRUE portion) to the Outputs statusCode field.
    4. Drag and drop the HTTP Raw Request statusCode field (the card in the Run When FALSE portion) to the Outputs statusCode field.
    5. Drag and drop the HTTP Raw Request body field (the card in the Run When TRUE portion) to the Outputs body field.
    6. Drag and drop the HTTP Raw Request body field (the card in the Run When FALSE portion) to the other Outputs body field.
    7. Save the Flow.
  • Create Connection Setting and Reauthorize Connection


    Note: The video shows the HTTP Raw Request card at the time that Okta published the tutorial. Okta changed the way that HTTP Raw Request worked so that it could securely store a token or use OAuth. Follow the steps to create the HTTP connection setting as demonstrated in the video and steps above.

  • Video Walkthrough