You are here:
< Back

Handling Custom Reports with NodeJs

When a custom report event hook is triggered it makes a POST request to with the event’s information in JSON format inside the request body.

We need to use the body-parser package to be able to parse the request’s body

const express = require('express');
const bodyParser = require('body-parser');
const app = express();

Then we can set up our endpoint which will handle the request

This example uploads the received information to a Google spreadsheet.'/CustomerAddedEvent', (request, response) => {
[[timeConverter(req.body.timestamp) , req.body.customerId, req.body.customerName, req.body.addedByUser, req.body.licenseCount]],
(status) => {
res.setHeader('Content-Type', 'application/json');
res.send({status: status});

You can find a CheatSheet to the body scheme of the event hooks here.