You are here:
< Back
When a custom report event hook is trigered 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();
app.use(bodyParser.json());

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

This example uploads the recieved information to a google spreadsheet.

app.post('/CustomerAddedEvent', (request, response) => {
console.log(req.body);
SpreadsheetHandler.writeValues(
spreadSheetId,
"CustomerAddedEvent!A1:E1",
[[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.