Execute a script using an HTTP REST request

This section describes how to use an HTTP REST request to execute a project created on HULFT Square.

Description

In this scenario, set the script created in Create a script that processes a CSV file as an API project, and by publishing it as a REST API, make it possible to execute it by HTTP REST request.

To execute an HTTP REST request and confirm the behavior, use the REST connector. Call it and execute it from Execute GET for the REST connector in Designer.

Follow the steps below to do so.

Procedures

(1) Create an API project

  • Select > API MANAGEMENT > API Projects.

  • On the API Projects page, select Add API Project.

  • In step General on the API Projects > Add New page, configure the settings as follows, and then select Next.

    Field name

    Setting (example)

    Name

    sampleAPI

    Workspace

    Personal

    Description

    (Optional)

    Base path

    HTTP_Request1

  • In step Summary, confirm the entered contents and select Finish.

(2) Add resources to the API project

  • On the API Projects page, select the Resources icon.

  • On the API Projects > sampleAPI > Resources page, select GET from of Add HTTP method.

  • In the right layer on the API Projects > sampleAPI > Resources page, configure the settings as follows and select Apply.

    Field name

    Setting (example)

    Project

    sample1*

    Version

    Set the latest version number.

    Script

    script*

    Response settings

    Response code

    200

    Response body

    Text, JSON

    *

    :

    The name and version of the project and the name of the script that you specified in the scenario Create a script that processes a CSV file.

    Settings for other items are optional.

(3) Create an API client

  • Select > API MANAGEMENT > API Clients.

  • On the API Clients page, select Create API Client.

  • In step General on the API Clients > Add New page, configure the settings as follows, and then select Next.

    Field name

    Setting (example)

    Name

    API_Client

    Description

    (Optional)

    Permitted users

    Select the users to call the endpoint from the member list (possible to choose multiple users).

    IP allowlist

    (Blank)

  • In step Summary, confirm the entered contents and select Finish.

(4) Create a REST API job

  • Select > JOBS > REST API Jobs.

  • On the REST API Jobs page, select Add.

  • In step General on the REST API Jobs > Add New page, configure the settings as follows, and then select Next.

    Field name

    Setting (example)

    Workspace

    Personal

    API project

    sampleAPI

    API project version

    Set the latest version number.

    Profile

    Choose a profile.

    Description

    (Optional)

  • In step API settings, configure the settings as follows, and then select Next.

    Field name

    Setting (example)

    API clients

    API_Client

  • In step Service to run scripts, configure the settings as follows, and then select Next.

    Field name

    Setting (example)

    Service to run scripts

    Set the name of the HULFT Integrate service that is running.

  • In step Summary, confirm the entered contents and select Finish.

    An endpoint is created automatically.

  • On the REST API Jobs page, select the Information icon.

  • On the REST API Jobs > sampleAPI page, copy the URL for the endpoint, and make a note of it in a text editor such as notepad.

    Use the copied information in the following steps.

(5) Create a destination for the REST connector

  • Select > HULFT INTEGRATE > Connections.

  • On the Connections page, select Add New.

  • In step Type on the Connections > Add New page, set REST connection, and then select Next.

  • In step General, configure the settings as follows, and then select Next.

    Field name

    Setting (example)

    Workspace

    Personal

  • In step Settings, configure the settings as follows, and then select Next.

    Field name

    Setting (example)

    URL

    Specify the URL of the VPC endpoint that you created by REST API job.

    Settings for other items are optional.

  • In step Profiles, configure the settings as follows, and then select Next.

    Field name

    Setting (example)

    Profile

    Choose a profile.

  • In step Summary, confirm the entered contents and select Finish.

(6) Place Execute GET for the REST connector in Designer

  • Select > HULFT INTEGRATE > Projects.

  • On the Projects page, select Create Project.

  • In step General on the Projects > Add New page, configure the settings as follows, and then select Next.

    Field name

    Setting (example)

    Name

    HTTP REST

    Workspace

    Personal

    Description

    (Optional)

    Create Script

    Select the checkbox.

    Script Name

    Script

  • In step Summary, confirm the entered contents and select Finish.

  • In the Edit HTTP REST dialog, configure the settings as follows, and then select Launch Designer.

    Field name

    Setting (example)

    Profile

    Choose a profile.

    Integrate service

    Specify the Integrate service specified in the scenario Create a script that processes a CSV file.

    Project version

    Select the latest version.

    Note

    To launch Designer, HULFT Square Designer.exe must be installed.

    = Remarks =

    If you select a profile, the connection is registered to the profile. The profile can be used to switch the resource settings.

  • Double-click a Script in the project explorer of Designer to open the script canvas.

  • Drag the component icon for Execute GET under Network > REST in the tool palette onto the script canvas.

  • In the Execute GET operation dialog, configure the settings as follows, and then select Finish.

    Required settings tab

    Field name

    Setting (example)

    Name

    (As desired)

    Destination

    REST connection (Personal)

    Header settings tab

    Field name

    Setting (example)

    Request header/Name

    Authorization

    Request header/Value

    Bearer <access token>*

    *

    :

    For details on access token creation, refer to Personal settings.

     

    When you want to execute REST API jobs asynchronously

    In this case, configure settings as follows:

    Field name

    Setting (example)

    Request header/Name

    X-HSQ-Async

    Request header/Value

    true

    Settings for other items are optional.

     

(7) Complete the script, and then execute the script

  • On the script canvas, connect Start, Execute GET, and End as shown below and complete the script.

  • Select Run script.

    The script starts, and then the message "Succeeded to run script." is displayed.

(8) Check the log

  • Select > SERVICE EVENTS > HULFT Integrate.

  • On the HULFT Integrate page, confirm that the specified script has been executed.

    Note

    When you don't specify asynchronous execution, the request timeout for REST API jobs is 29 seconds. When a script executed by a REST API job takes more than 29 seconds, the REST API job returns a timeout error to the HTTP client even if the script is still running.

    Check the completion of scripts registered in REST API jobs by filtering by Project in > SERVICE EVENTS > HULFT Integrate as needed.