Flow Connect Help
Roadmap
  • ℹ️This is Flow Connect
    • Overview
    • Technical overview
      • System requirements
    • What's new?
      • Change log
  • ▶️quick start
    • Create an application
    • Create an admin access group
  • 🔁working with Connect
    • Connect to systems
      • Connector agents
        • Add agent group
        • Install agent manager
        • Add agent
        • Manage agent
      • Connectors
        • IFS Applications 10
        • Oracle
        • Microsoft SQL Server
        • Send Email
        • REST
          • Microsoft Graph API
          • Infor M3 REST
            • Obtaining Infor ION API file
            • Configure REST Connector with ION API file
          • IFS Cloud
            • IAM Client Registration
            • Obtaining end-point info from IFS Cloud
            • Configure REST Connector for IFS Cloud
        • File System
      • Redirect URIs
    • Create and design
      • Application packages
      • Applications
        • Create
        • Design
        • Test
        • Commit
      • Portal Pages
        • Create Portal Page
        • Design Portal Page
        • Commit Portal Page
      • Components
        • Create component
        • Manage component
      • Modules
        • Create module
        • Manage module
      • Automations
        • Functionality
        • Create Automation
        • Manage Automation
        • Creating Access Key
        • Executing Automations Externally
          • IFS Cloud
          • Salesforce Apex Trigger Example
    • Deploy
      • Environments
      • Deploy
    • Use
      • On mobile devices
      • In web browser - Web client
      • In web browser - Portal
    • Share
      • Share Applications
    • User administration
      • Users
        • Invite a new user
        • Manage users
      • User groups
        • Create user groups
        • Manage user groups
      • Access
        • Manage access
  • ⏸️Reference
    • How-to guides
      • Create User Step controls
        • Header
        • Static text
        • Labelled static text
        • Link
        • Image viewer
        • Text input
        • Numeric input
        • Date input
        • Time input
        • Check box input
        • Binary option input
        • List selection input
        • List multi-selection input
        • Menu selection input
        • Data grid
        • Calendar control
        • Image selection input
        • List presentation
        • Camera Input
      • Dependent controls in User step
        • Variable source
        • Expression source
        • Control visibility (condition to hide)
      • Configure SSO for Microsoft Entra
    • Reference
      • Clients
        • Settings
        • My data
      • Designer
        • Controls
          • Header
          • Static text
          • Labeled static text
          • Link
          • External app launcher
          • Image viewer
          • Text input
          • Numeric input
          • Date input
          • Time input
          • Check box input
          • Binary option input
          • List selection input
          • List multi-selection input
          • Menu selection input
          • Data grid
          • Calendar
          • Image selection input
          • List presentation
          • Camera input
          • File gallery
          • GPS location input
          • Signature capture input
          • Item creation sub task
          • Check list sub task
          • Verb sub task
        • Steps
          • Start
          • User interaction
          • External system
          • Decision
          • Assertion
          • HTTP requests
          • Assignment
          • Table
          • Event listener
          • Checkpoint
          • Script
          • Annotation
          • End
          • Local data resource
      • Portal
        • Design items
          • Portlets
            • Accumulation chart
            • Base chart
            • Circular gauge
            • Custom content
            • Data tree
            • Document viewer
            • Filter
            • Kanban
            • KPI card
            • Link
            • My apps
            • Record
            • Rich text
            • Table
          • Container
          • Common portlet configuration
            • General
            • Events
            • Data
            • Custom buttons
            • Style
        • Portal settings
          • Branding
          • Page
          • Navigation
        • Profile
        • Portlet actions
        • Cache
        • Input to Start Step
      • Diagnostic mode
      • FlowScript
        • Walkthrough
          • Introduction
          • Expressions and programs
          • Anatomy of a program
          • Variables
          • Simple types
          • Nullable types
          • Records
          • Sequences
          • Other types
          • Arithmetic
          • Other expressions
          • Queries
          • Conditionals and loops
          • Function definitions
          • Built-in functions
          • DateTime module
          • Seq module
          • HTTP module
          • CSV module
          • JSON module
          • Trace module
          • Record module
          • XML Module
          • Filesystem Module
          • Custom modules
          • Custom Types
          • Appendix: Subtyping rules
          • Appendix: Escape sequences
          • Appendix: Type checking errors
      • Flowscript Copilot
      • Glossary
    • Flow Connect Downloads
      • Install Flow Connect Designer
    • Migrate from Flow Classic
      • Portal - migrate from Flow Classic
      • Classic vs. Connect Comparison Guide
Powered by GitBook
On this page
  • Requests and responses
  • Request headers
  • Response status code
  • Response headers
  • HTTP module functions
  • getText
  • getBinary
  • postText
  • postBinary
  • patchText
  • patchBinary
  • putText
  • putBinary
  • head
  • delete

Was this helpful?

  1. Reference
  2. Reference
  3. FlowScript
  4. Walkthrough

HTTP module

PreviousSeq moduleNextCSV module

Last updated 1 year ago

Was this helpful?

The HTTP module is used to make HTTP requests from Flow Connect applications.

Requests and responses

Request headers

All the functions in the HTTP module provide the option to specify request headers. The request headers are specified as records. If you do not want to specify any request headers, you can use an empty record {}.

// Example 1: Make an HTTP request with no headers
return HTTP.getText("https://www.novacura.com", { });
// Example 2: Make an HTTP request with an Accept header
return HTTP.getText(
    "https://jsonplaceholder.typicode.com/todos/1",
    {
        "Accept" : "application/json"
    });

Response status code

The responses from the functions in the HTTP module contain an indicating whether the request was successful. Generally, status codes between 200 and 299 are considered successful. It is the responsibility of the Flow developer to check the status code of each response from the HTTP module.

The reasonPhrase member of the responses contain a textual description of the status code.

// Example: check whether an HTTP response indicates success.
// In this example, we request a page which does not exist.

let response = HTTP.getText("https://www.novacura.com/does_not_exist.html", { });
if response.statusCode >= 200 and response.statusCode <= 299:
    return "OK";
else:
    error "The request failed with status code "
          & response.statusCode
          & " "
          & response.reasonPhrase;
// Example: create a utility function "ensureSuccess" which raises
// an error if a response is unsuccessful and returns the contents otherwise.

function isSuccess(response: { statusCode: number }) =>
    response.statusCode >= 200 and response.statusCode <= 299;

function ensureSuccess<T>(self response: { statusCode: number, reasonPhrase: text, contents: T }) : T {
    return case when isSuccess(response)
                then response.contents
                else error "The request failed with status code " & response.statusCode & " " & response.reasonPhrase
                end;
}

// Make a request for a nonexistent page.
return HTTP.getText("https://www.novacura.com/does_not_exist.html", { })
           .ensureSuccess();

Response headers

The responses from the functions in the HTTP module also contain response headers. Unlike the request headers, the response headers are formatted as a sequence of key/value pairs where each entry may have more than one value.

// Example: extract a Cookie header from an HTTP response.

let response = HTTP.getText("https://www.google.com", {});
let cookie = null;

// Look for a cookie in the response headers
let header = firstOrNull(response.headers where name = "Set-Cookie")
if header != null:
    cookie = first(header.values);

return cookie;

HTTP module functions

getText

Signature: (url: text, headers: { }) -> HTTPResponse<text>

Makes an HTTP GET request with the specified URL and headers. The returned record contains the response data (if any) as a text value.

getBinary

Signature: (url: text, headers: { }) -> HTTPResponse<binary>

Makes an HTTP GET request with the specified URL and headers. The returned record contains the response data (if any) as a binary value.

postText

Signature: (url: text, headers: { }, body: text) -> HTTPResponse<text>

Makes an HTTP POST request with the specified URL, headers and body. The body is taken in text format, and the returned record contains the response data (if any) as a text value. If no Content-Type header is specified, the Content-Type will be passed as text/plain.

postBinary

Signature: (url: text, headers: { }, body: binary) -> HTTPResponse<binary>

Makes an HTTP POST request with the specified URL, headers and body. The body is taken in binary format, and the returned record contains the response data (if any) as a binary value. No Content-Type header is added automatically.

patchText

Signature: (url: text, headers: { }, body: text) -> HTTPResponse<text>

Makes an HTTP PATCH request with the specified URL, headers and body. The body is taken in text format, and the returned record contains the response data (if any) as a text value. If no Content-Type header is specified, the Content-Type will be passed as text/plain.

patchBinary

Signature: (url: text, headers: { }, body: binary) -> HTTPResponse<binary>

Makes an HTTP PATCH request with the specified URL, headers and body. The body is taken in binary format, and the returned record contains the response data (if any) as a binary value. No Content-Type header is added automatically.

putText

Signature: (url: text, headers: { }, body: text) -> HTTPResponse<text>

Makes an HTTP PUT request with the specified URL, headers and body. The body is taken in text format, and the returned record contains the response data (if any) as a text value. If no Content-Type header is specified, the Content-Type will be passed as text/plain.

putBinary

Signature: (url: text, headers: { }, body: binary) -> HTTPResponse<binary>

Makes an HTTP PUT request with the specified URL, headers and body. The body is taken in binary format, and the returned record contains the response data (if any) as a binary value. No Content-Type header is added automatically.

head

Signature: (url: text, headers: { }) -> HTTPResponseNoBody

Makes an HTTP HEAD request with the specified URL and headers. The returned value has no contents, only status code, reason phrase and response headers.

delete

Signature: (url: text, headers: { }) -> HTTPResponseNoBody

Makes an HTTP DELETE request with the specified URL and headers. The returned value has no contents, only status code, reason phrase and response headers.

⏸️
HTTP status code