Execute Hook

It is used to execute a hook.

Before you begin

Before attempting to submit a request with this API, you must ensure that the following permissions are available:
  • Service Requests > Action > View all requests
  • Service Requests > Action > View my requests
  • Automation > Service Requests > Action > Trigger.
You can check this in the Platform module under IDENTITY > Role > Authorized functions.

Request Structure

Endpoint: /execute-hook
Type: POST
Sample URL: https://<IP/HostName/TenantName>:<GWPORT>/avxapi/execute-hook?gwsource=external

To understand the elements of the sample URL, click here.

Headers:
Content-Type: application/json
Table 1. Input Parameters
Name Description
sessionID

Header

(Mandatory) Use session ID retrieved from login API is required if username and password are not provided.

Example: "sessionId": "ce7f1a14-2bf9-4e4a-89a8-bc780a255813"

username

Header

(Mandatory) AppViewX login username is required if sessionId is not provided.

Example: "admin"

password

Header

(Mandatory) AppViewX login password is required if sessionId is not provided..

Example: "AppViewX@123"

Content-Type

Header

(Mandatory) The parameter should be set to application/json to specify the nature of the data in the payload.

Example: "application/json"

gwsource

Query

(Mandatory) Source from which the request is triggered. The values can be:
  • web
  • external
Payload

Body

map, Object

(Mandatory) Contains all the params to be sent in the request body for the post request.

Type: String

Response Structure

  • Status Code: 200 OK
  • Message: Success
  • Headers:
    • Content-Type: application/json
Table 2. Response Parameters
Name Description
response

Key value pair

Contains the response object along with the hierarchy of the object mapped in field children.
message

String

Success message or failure description in case of error.
appStatusCode

String

Application specific status code for the response. Will be non-null for failure response.
tags

NA

More info in case of failure response.

Status Codes

HTTP Code appStatusCode Message and Remediation
200 OK NA Success
500 Internal Error NA Invalid Hook Type.

Possible Remediation:Check whether the given hook type is either api or script or query.

500 Internal Error automation-hook-1012 Could not parse/convert Object to Json or Vice versa.

Possible Remediation: Check whether the output is either an object or json.

500 Internal Error automation-hook-1013 Error in rest communication.

Possible Remediation: Check whether the details provided for rest call is valid.

Sample Request/Response

Use Case:

To execute a hook.

Request URL
https://<IP/HostName/TenantName>:<GWPORT>/avxapi/execute-hook?gwsource=external
Request Payload
{
    "payload": {
        "hook": {
            "name": "Rest API"
        }
    }
}
Sample Response
{
    "response": {
        "status": "Success",
        "output": {
            "access_token": *******,
            "refresh_token": ******,
            "scope": "useraccount",
            "token_type": "Bearer",
            "expires_in": 1799
        },
        "type": "rest"
    },
    "message": null,
    "appStatusCode": null,
    "tags": null,
    "headers": null
}

Reference

Understanding the sample URL
  • IP/HostName/TenantName: Replace with the actual IP address, hostname, or tenant name based on the specific configuration in AppViewX.
    • IP: A unique identifier assigned to each device connected to a computer network that uses the Internet Protocol for communication

      The IP address will be included in the endpoint URL for an on-prem deployment.

    • HostName: A human-readable label assigned to a device (host) on a network

      The hostname will be included in the endpoint URL for an on-prem deployment.

    • TenantName: An identifier label for a tenant given to indicate which tenant's data the API request will access/modify

      The tenant name will be included in the endpoint URL for a SaaS deployment.

  • GWPORT: AppViewX gateway port

    A gateway port refers to a network port through which data is sent and received to communicate with a gateway in an on-prem deployment.

    Example: 31443

  • avxapi: Path parameter value (static) that is part of the endpoint's URL
  • Endpoint: Endpoint of the API, for example: execute-hook
  • gwsource: Source or origin of a gateway, for example: external.