function getServiceNowIncidentIdFromURL(url){

    return xapi.command('HttpClient Get', { 'Header': [CONTENT_TYPE, SERVICENOW_AUTHTOKEN] , 'Url':url, 'AllowInsecureHTTPS': 'True'});

}
function raiseTicket(message){
    console.log('Message raiseTicket: ' + message);
    var messagecontent = {      description: systemInfo.softwareVersion      , short_description: message    };

     xapi.command('HttpClient Post', { 'Header': [CONTENT_TYPE, SERVICENOW_AUTHTOKEN] , 'Url':MONITORING_URL, 'AllowInsecureHTTPS': 'True'}
     , JSON.stringify(messagecontent)).then(
    (result) => {
      const serviceNowIncidentLocation = result.Headers.find(x => x.Key === 'Location');
      var serviceNowIncidentURL = serviceNowIncidentLocation.Value;
     var  serviceNowIncidentTicket;
     getServiceNowIncidentIdFromURL(serviceNowIncidentURL).then(
    (result) => {
        var body = result.Body;
        console.log('Got this from getServiceNowIncidentIdFromURL: ' + JSON.stringify(result));
        serviceNowIncidentTicket =  JSON.parse(body).result.number;
          xapi.command("UserInterface Message Alert Display", {
              Title: 'ServiceNow receipt'
              , Text:  'Your ticket id is ' + serviceNowIncidentTicket + '. Thanks for you feedback! Have an awesome day!'
              , Duration: 10
          }).catch((error) => { console.error(error); })
    });

        console.log('Got this from raiseTicket: ' + JSON.stringify(result));
    });
}