# HTTP Plugin

# General information

The HTTP Plugin is a built-in module in the Acure agent application since version 1.1.0.

The HTTP Plugin allows you to execute HTTP requests specified by the user in the Data stream in the form of a YAML script, and supports the following HTTP request methods:

  • GET
  • POST
  • PUT
  • DELETE

Download Agents using following links:

- Agent for Windows (opens new window)

- Agent for Linux (opens new window)

# The script format of HTTP plugin

name: HTTP Request
jobs:
- name: HTTP Request
  steps:
    - plugin: httpPlugin
      with:
        url: {url}
        method: {GET | POST | PUT | DELETE}
        headers:
            {header_name}: {header_value}
            {header_name}: {header_value}
            ...
        body: "{...}"
        basicauth:
            login: {login}
            password: {password}
        port: {port_number}
        proxy:
            address: {url}
            bypasslist:
              - {url}
              - {url}
                ...
            credentials:
                login: {login}
                password: {password}
        redirects: {true | false}
        insecure: {true | false}
        queryparams:
            {param_name}: {param_value}
            {param_name}: {param_value}
            ...

# Configuration parameters used in the script

Parameter Type Default value Description
url string no URL of the resource to which the request will be executed
method string GET HTTP request method
streamId string no Current thread ID ($.vars.stream.id)
streamKey string no API key of the current stream ($.vars.stream.key)
headers list[] no Request header list
body string no Request body (required in quotes)
basicauth: login string no Login Basic Auth
basicauth:password string no Password Basic Auth
port Integer no The numeric value of the server port to which the request will be addressed
proxy:address string no URL of the proxy server through which the request will pass
proxy:bypasslist string no An array of addresses or regular expressions that describe addresses that will not use proxies for queries
proxy:credentials:login string no Login for http-authentication on the proxy-server
proxy:credentials:password string no Password for http authentication on the proxy server
redirects Boolean false Parameter that allows the request to follow redirects
secure Boolean false Option to allow the request to perform an insecure SSL connection
queryparams list[] no List of query parameter variables

Required parameters

  • url - URL of the resource to which the request will be made
  • method - HTTP request method
  • streamId - Current stream ID ($.vars.stream.id)
  • streamKey - API key of the current stream ($.vars.stream.key)
  • The headers parameter is specified in the following format:

    headers:
      Accept: "application/json"
      {header_name1}: {header_value1}
      {header_name2}: {header_value2}
      {header_name3}: {header_value3}
    
  • The queryparams parameter is specified in the following format:

  • queryparams:
        key: my_key
        {param_name1}: {param_value1}
        {param_name2}: {param_value2}
        {param_name3}: {param_value3}
    

💡 If query parameters are both specified in url and as queryparams parameters in the task, the final request will contain all parameters.

# Response template

The response to the request from the server is parsed and converted into the following JSON format:

{
    "StatusCode": "200",
    "Headers": [
        {
            "Key": "",
            "Value": [
                ""
            ]
        }
    ],
    "IsSuccessStatusCode": true,
    "ResponseData": {},
    "Error": "" 
}
  • StatusCode - HTTP response code
  • Headers - array of response headers
  • ResponseData - data in text format received in the response
  • IsSuccessStatusCode - request success flag (true/false)
  • Error - error text if IsSuccessStatusCode == false

# An example of making a request to Zabbix API

name: Zabbix Request
jobs:
- name: Zabbix Request
  steps:
    - plugin: httpPlugin
      with:
        url: https://zabbix.domain.com/api_jsonrpc.php
        streamId: $.vars.stream.id
        streamKey: $.vars.stream.key
        method: POST
        headers:
            Content-Type: application/json
        body: '{"jsonrpc":"2.0","method":"host.get","id":2,"auth":"{token}","params":{"output":["hostid","host","maintenance_status","name","status"]}}'