HTTP request type

Introduction 

With the HTTP Request Credential type, data retrieved from the response of an HTTP Request can be securely supplied to actions. When an action with a HTTP Request credential runs, Tines will run the corresponding HTTP Request options in the background and embed the data at the specified path in the response.

If the HTTP Request fails, you can navigate to the credential log tab to see the logged error message to help with debugging.

Creating a HTTP Request Credential 

When creating a HTTP Request Credential, you will need to specify the name of the credential, HTTP Request options and the JSONPath where the data that should be used in the credential can be located in the response.

Example 

Suppose we have HTTP Request options that make a request to a service to get an access token for subsequent requests. The action config for this action is shown below:

{
  "url": "https://www.token-generator.com/oauth2/token",
  "content_type": "form",
  "method": "post",
  "payload": {
    "assertion": "{{ .CREDENTIAL.token_generator }}"
  }
}

When this action runs, it emits an event similar that shown below:

{
  "get_auth_token": {
    "body": {
      "access_token": "ya29.Gn9qB-2K9xbys1DCgzyXNrIWuIIE0CuoAuSj5dYqWiMa7JNjarCZxhjgxbPkAGtADLIck87KIuDtYp3o71NRppfyA2tpTfD1uRG6lsjfoQD4g86jbzyjcTLbOn-oD_i8eQf4hQnUhkcrrktQ70GBJmnLwrOCaH7bTthMQLzV21p5",
      "expires_in": 3600,
      "token_type": "Bearer"
    },
    "headers": {},
    "status": 200
  }
}

We would use the access_token defined at {{.get_auth_token.body.access_token}} in subsequent requests.

We can now use another HTTP Request to make requests using the new credential. When the below action runs, it will first run the Get auth token credential in the background, extract the returned access_token and embed it in Authorization header with a CREDENTIAL formula expression:

{
  "url": "https://www.another-service.com/admin/login",
  "content_type": "json",
  "method": "get",
  "headers": {
    "Authorization": "Bearer <<.CREDENTIAL.get_auth_token>>"
  }
}
Was this helpful?