Skip to content

HTTP Request

Summary

  • Internal name: HttpRequest
  • Category: Communication
  • Purpose: Perform an HTTP GET or POST request with configurable parameters, headers, body, and timeouts. Returns the HTTP response code and body.
  • Task type: Normal

Compatibility

  • Minimum AndroMate version: 1.1.0

  • Maximum AndroMate version: 1.1.0

  • Minimum Android: Android 13 (API 33)

  • Maximum Android tested: Android 16 (API 36)

  • Required permissions:

    • INTERNET
    • ACCESS_NETWORK_STATE

Detailed description

The HTTP Request task performs an HTTP GET or POST request to the specified url. Parameters, headers, and the request body are configured individually. Connection and read timeouts are controlled separately. Debug logging can be enabled via httpDebug.

The task resolves all dynamic variables in url, headers, parameters, and body before executing the request. On success, the HTTP response code and response body are stored in the output variables from HttpRequestResult. An IOException during execution raises HTTP-ERROR-001.


Input parameters

Parameter Type Required Possible values Android Compatibility AndroMate Compatibility Default
url String Yes Valid HTTP/HTTPS URL — supports $variable Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 ""
method String No "GET", "POST" Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 "GET"
connectionTimeout Long No Connection timeout in milliseconds Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 5000
readTimeout Long No Read timeout in milliseconds Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 5000
httpDebug Boolean No true / false — enable debug logging Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 false
parameters JSONArray No List of {"param_name": "...", "value": "..."} objects Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 []
headers JSONArray No List of {"header_name": "...", "value": "..."} objects Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 []
body String No Raw request body string Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 ""

Output parameters

Field Type Trigger condition Android Compatibility AndroMate Compatibility Default
responseCode_output String (Integer) Always on success — HTTP status code Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 <ANDROMATE_NULL_VALUE>
responseBody_output String Always on success — response body string Android 13 (API 33) → Android 16 (API 36) 1.1.0 → 1.1.0 <ANDROMATE_NULL_VALUE>

Note: Output variables are only written if the corresponding workflow variable already exists in the execution context (declared in the Start task).


Exceptions

Code Exception Name Description
HTTP-ERROR-001 HTTP I/O Error An IOException occurred during HTTP execution (from AndromateExceptionTypes.HTTP_REQUEST_IO_EXCEPTION_ERROR).

Execution flowchart

flowchart TD
    Start([▶ HttpRequest]) --> ResolveParams[🔄 Resolve url, headers,\nparameters, body]

    ResolveParams --> CreateClient[🔗 Create HTTP client\nmethod, connectionTimeout, readTimeout, httpDebug]

    CreateClient --> Execute[📡 Execute HTTP request\nGET or POST]

    Execute -->|IOException| E1[❌ HTTP-ERROR-001\nHTTP I/O Error]
    Execute -->|Success| GetResponse[📥 Get response body\n+ HTTP status code]

    GetResponse --> StoreResult[💾 Store HttpRequestResult\nresponseCode_output\nresponseBody_output]

    StoreResult --> LogReport[📋 Log report\nReportSection]

    LogReport --> Success([✅ HttpRequestResult])

    E1 --> Error([❌ Exception])

    style Start fill:#e3f2fd
    style Success fill:#c8e6c9
    style Error fill:#ffcdd2
    style E1 fill:#ffcdd2
    style ResolveParams fill:#fff9c4
    style CreateClient fill:#f3e5f5
    style Execute fill:#f3e5f5
    style GetResponse fill:#fff9c4
    style StoreResult fill:#c8e6c9

How it works:

  1. Resolve parameters: resolves dynamic variables in url, headers, parameters, and body
  2. Create HTTP client: initializes the HTTP client with method, connectionTimeout, readTimeout, and httpDebug
  3. Execute request: sends the HTTP GET or POST request
  4. On IOException: throws HTTP-ERROR-001
  5. Get response: retrieves the response body and HTTP status code
  6. Store result: saves results in HttpRequestResultresponseCode_output and responseBody_output
  7. Log report: records the execution report
  8. Result: returns HttpRequestResult

Code examples

Example 1 — Simple GET request

{
  "HttpRequest": [
    {
      "id": "1",
      "title": "GET device status",
      "url": "https://api.example.com/status",
      "method": "GET",
      "responseCode_output": "$http_status",
      "responseBody_output": "$http_body"
    }
  ]
}

Example 2 — POST request with JSON body

{
  "HttpRequest": [
    {
      "id": "2",
      "title": "POST device report",
      "url": "https://api.example.com/report",
      "method": "POST",
      "connectionTimeout": 5000,
      "readTimeout": 10000,
      "body": "{ \"deviceId\": \"$DEVICE_ID\", \"status\": \"ok\" }",
      "headers": [
        { "header_name": "Content-Type", "value": "application/json" },
        { "header_name": "Authorization", "value": "Bearer $TOKEN" }
      ],
      "responseCode_output": "$http_code",
      "responseBody_output": "$http_response"
    }
  ]
}

Example 3 — GET request with query parameters

{
  "HttpRequest": [
    {
      "id": "3",
      "title": "GET with parameters",
      "url": "https://api.example.com/monitoring",
      "method": "GET",
      "parameters": [
        { "param_name": "deviceId", "value": "$DEVICE_ID" },
        { "param_name": "session", "value": "$SESSION_ID" }
      ],
      "httpDebug": true,
      "responseCode_output": "$status_code",
      "responseBody_output": "$response_body"
    }
  ]
}

Example 4 — POST with custom timeouts

{
  "HttpRequest": [
    {
      "id": "4",
      "title": "POST with extended timeouts",
      "url": "$api_endpoint",
      "method": "POST",
      "connectionTimeout": 10000,
      "readTimeout": 30000,
      "body": "$request_payload",
      "headers": [
        { "header_name": "X-API-Key", "value": "$API_KEY" }
      ],
      "responseCode_output": "$resp_code",
      "responseBody_output": "$resp_body"
    }
  ]
}

Input parameter details

1. url — Target URL

The HTTP or HTTPS URL of the endpoint to call. Supports $workflow_variable references — resolved at runtime.

  • Default: ""
  • Supports variables: Yes

2. method — HTTP method

The HTTP method used for the request.

Value Description
"GET" Retrieve data from the server — parameters appended to URL
"POST" Send data to the server — body or parameters in request body
  • Default: "GET"

3. connectionTimeout — Connection timeout

Maximum time in milliseconds to establish the HTTP connection.

  • Type: Long
  • Default: 5000 (5 seconds)

4. readTimeout — Read timeout

Maximum time in milliseconds to wait for the server response after the connection is established.

  • Type: Long
  • Default: 5000 (5 seconds)

5. httpDebug — Debug logging

When true, enables verbose HTTP debug logging in the task report.

  • Default: false

6. parameters — Query/body parameters

A JSON array of parameter objects, each with param_name and value fields. Parameters are appended to the URL for GET requests or included in the request body for POST requests.

"parameters": [
  { "param_name": "deviceId", "value": "$DEVICE_ID" },
  { "param_name": "type", "value": "diagnostic" }
]
  • Default: []

7. headers — HTTP headers

A JSON array of header objects, each with header_name and value fields. Added to every request.

"headers": [
  { "header_name": "Authorization", "value": "Bearer $TOKEN" },
  { "header_name": "Content-Type", "value": "application/json" }
]
  • Default: []

8. body — Raw request body

A raw string body sent with the request. Typically used with POST. Supports $workflow_variable references.

"body": "{ \"deviceId\": \"$DEVICE_ID\" }"
  • Default: ""

Output parameter details

responseCode_output — HTTP response code

Stores the HTTP status code returned by the server as a string (from HttpRequestResult).

  • Examples: "200" (OK), "201" (Created), "400" (Bad Request), "500" (Server Error)
  • Written on every successful HTTP exchange (regardless of HTTP status value)

responseBody_output — HTTP response body

Stores the raw response body string returned by the server (from HttpRequestResult).

  • Written on every successful HTTP exchange
  • May be empty if the server returns no body

Complete JSON example

{
  "HttpRequest": [
    {
      "id": "1",
      "title": "HTTP Request",
      "url": "https://api.example.com/monitoring",
      "method": "POST",
      "connectionTimeout": 5000,
      "readTimeout": 10000,
      "httpDebug": true,
      "body": "{ \"deviceId\": \"$DEVICE_ID\" }",
      "parameters": [
        { "param_name": "deviceId", "value": "$DEVICE_ID" }
      ],
      "headers": [
        { "header_name": "Authorization", "value": "Bearer $TOKEN" }
      ],
      "responseCode_output": "$HTTP_STATUS",
      "responseBody_output": "$HTTP_RESULT"
    }
  ]
}