Chilkat Online Tools

Node.js / Squadcast API V3 / Incident Export

Back to Collection Items

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}


function chilkatExample() {

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var http = new chilkat.Http();
    var success;

    var queryParams = new chilkat.JsonObject();
    queryParams.UpdateString("start_time","2020-08-16T11:43:51.947Z");
    queryParams.UpdateString("end_time","2020-08-16T11:43:51.947Z");
    queryParams.UpdateString("status","resolved");
    queryParams.UpdateString("type","csv");
    queryParams.UpdateString("services","5c7cf6bff8dde3001282aa56");
    queryParams.UpdateString("services","5c7cf6bff8dde3001282aa57");
    queryParams.UpdateString("assigned_to","5c7cf6bff8dde3001282aa33");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.AuthToken = "<access_token>";

    // resp: HttpResponse
    var resp = http.QuickRequestParams("GET","https://api.squadcast.com/v3/incidents/export/",queryParams);
    if (http.LastMethodSuccess == false) {
        console.log(http.LastErrorText);
        return;
    }

    console.log(resp.StatusCode);
    console.log(resp.BodyStr);


}

chilkatExample();

Curl Command

curl -G -d "start_time=2020-08-16T11%3A43%3A51.947Z"
	-d "end_time=2020-08-16T11%3A43%3A51.947Z"
	-d "status=resolved"
	-d "type=csv"
	-d "services=5c7cf6bff8dde3001282aa56"
	-d "services=5c7cf6bff8dde3001282aa57"
	-d "assigned_to=5c7cf6bff8dde3001282aa33"
	-H "Authorization: Bearer <access_token>"
https://api.squadcast.com/v3/incidents/export/

Postman Collection Item JSON

{
  "name": "Incident Export",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{sq_pb_auth_header}}",
          "type": "string"
        }
      ]
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/incidents/export/?start_time=2020-08-16T11:43:51.947Z&end_time=2020-08-16T11:43:51.947Z&status=resolved&type=csv&services=5c7cf6bff8dde3001282aa56&services=5c7cf6bff8dde3001282aa57&assigned_to=5c7cf6bff8dde3001282aa33",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "incidents",
        "export",
        ""
      ],
      "query": [
        {
          "key": "start_time",
          "value": "2020-08-16T11:43:51.947Z"
        },
        {
          "key": "end_time",
          "value": "2020-08-16T11:43:51.947Z"
        },
        {
          "key": "status",
          "value": "resolved"
        },
        {
          "key": "type",
          "value": "csv"
        },
        {
          "key": "services",
          "value": "5c7cf6bff8dde3001282aa56"
        },
        {
          "key": "services",
          "value": "5c7cf6bff8dde3001282aa57"
        },
        {
          "key": "assigned_to",
          "value": "5c7cf6bff8dde3001282aa33"
        }
      ]
    },
    "description": "- This endpoint is used to export the incident details into a `csv` or `json` file.\n- Requires `access_token` as a `Bearer {{token}}` in the `Authorization` header.\n- Header field/value: `Content-Type`: `text/csv`\n\n\nQuery Params:\n```\ntype: csv or json\n\nstart_time: filter by date range\n\nend_time: filter by date range\n\nservices: filter by services\n\nsources: filter by alert sources\n\nassigned_to: filter by assignee\n\nstatus: filter by incident status\n```"
  },
  "response": [
    {
      "name": "200 OK",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/incidents/export/?start_time=2020-08-16T11:43:51.947Z&end_time=2020-08-16T11:43:51.947Z&status=resolved&type=csv&services=5c7cf6bff8dde3001282aa56&services=5c7cf6bff8dde3001282aa57&assigned_to=5c7cf6bff8dde3001282aa33",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "incidents",
            "export",
            ""
          ],
          "query": [
            {
              "key": "start_time",
              "value": "2020-08-16T11:43:51.947Z"
            },
            {
              "key": "end_time",
              "value": "2020-08-16T11:43:51.947Z"
            },
            {
              "key": "status",
              "value": "resolved"
            },
            {
              "key": "type",
              "value": "csv"
            },
            {
              "key": "services",
              "value": "5c7cf6bff8dde3001282aa56"
            },
            {
              "key": "services",
              "value": "5c7cf6bff8dde3001282aa57"
            },
            {
              "key": "assigned_to",
              "value": "5c7cf6bff8dde3001282aa33"
            }
          ]
        }
      },
      "_postman_previewlanguage": null,
      "header": null,
      "cookie": [
      ],
      "body": null
    },
    {
      "name": "401 Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/incidents/export/?start_time=2020-08-16T11:43:51.947Z&end_time=2020-08-16T11:43:51.947Z&status=resolved&type=csv&services=5c7cf6bff8dde3001282aa56&services=5c7cf6bff8dde3001282aa57&assigned_to=5c7cf6bff8dde3001282aa33",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "incidents",
            "export",
            ""
          ],
          "query": [
            {
              "key": "start_time",
              "value": "2020-08-16T11:43:51.947Z"
            },
            {
              "key": "end_time",
              "value": "2020-08-16T11:43:51.947Z"
            },
            {
              "key": "status",
              "value": "resolved"
            },
            {
              "key": "type",
              "value": "csv"
            },
            {
              "key": "services",
              "value": "5c7cf6bff8dde3001282aa56"
            },
            {
              "key": "services",
              "value": "5c7cf6bff8dde3001282aa57"
            },
            {
              "key": "assigned_to",
              "value": "5c7cf6bff8dde3001282aa33"
            }
          ]
        }
      },
      "_postman_previewlanguage": null,
      "header": null,
      "cookie": [
      ],
      "body": null
    },
    {
      "name": "400 Bad Request",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/incidents/export/?start_time=2020-08-16T11:43:51.947Z&end_time=2020-08-16T11:43:51.947Z&status=resolved&type=csv&services=5c7cf6bff8dde3001282aa56&services=5c7cf6bff8dde3001282aa57&assigned_to=5c7cf6bff8dde3001282aa33",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "incidents",
            "export",
            ""
          ],
          "query": [
            {
              "key": "start_time",
              "value": "2020-08-16T11:43:51.947Z"
            },
            {
              "key": "end_time",
              "value": "2020-08-16T11:43:51.947Z"
            },
            {
              "key": "status",
              "value": "resolved"
            },
            {
              "key": "type",
              "value": "csv"
            },
            {
              "key": "services",
              "value": "5c7cf6bff8dde3001282aa56"
            },
            {
              "key": "services",
              "value": "5c7cf6bff8dde3001282aa57"
            },
            {
              "key": "assigned_to",
              "value": "5c7cf6bff8dde3001282aa33"
            }
          ]
        }
      },
      "_postman_previewlanguage": null,
      "header": null,
      "cookie": [
      ],
      "body": null
    }
  ]
}