Accessing data from the response

Hello, I have a serverless app that creates an incident in serviceNow when I create a ticket in Freshdesk.

I am working on the onTicketUpdateCallback and need to extract the id of theincident created in SNOW that comes in the response body from ServiceNow ( in this case, service now calls it the “sys_id” property)

What is the proper way of doing this in a serverless app ?
here is an example of my simple serverless onTicketCreate event:

onTicketCreateCallback : function(args) {
    let map = { this is node-transform where I have to transform the JSON to populate the service Now 
    incident table }
    let headers = {headers info};
    let body = JSON.stringify(map);
    let options = {headers, body }

    .then(function(data)  { 
        console.log('success' +  JSON.stringify(data)); here is where i see the response JSON.

        CODE TO EXTRACT ID PROPERTY? no matter what i do i seem to get Type error - Cannot get property of 
        'sys_id' Undefined or {}
    function(err) {
    what is the common way for getting the json property from the response body in freshdesk? 

Thank you

Hey Craig,
I am not sure of what you are exactly looking for. Can you please confirm whether the response data is received and available before parsing and extracting the “sys_id” property?

If you successfully receive the response data then the issue might be because of searching for “sys_id” property in a string. Kindly convert the response data to object using JSON.parse(data) and then try to access it.

1 Like

Thank you for your reply. I wasn’t parsing correctly.

solution -> var parsed = JSON.parse(data.response);
var sys_id = parsed.result.sys_id;