How to send delivery acknowledgement and process acknowledgement to third party in REST integration?

Pravitha
Tera Contributor

I want to send a delivery acknowledgement when I'm receiving an update request from third party in REST integration, and I have to again send them a process acknowledgment after I parse this update request to the staging table and process it, how to achieve this via Scripted Rest API? Any other ways to accommodate this functionality?

 

Below is the sample delivery acknowledgement which third party expecting from me:

{
"dack": {
"returnCode": 0,
"header": {
"messageID": 1168XXX51,
"srcApplicationID": "XXXXX-SNOW-C"
},
"ticketID": "INC00XXXX"
}
}

 

Below is the sample process acknowledgement which third party expecting from me:

{
"pack":{
"masterID":"",
"returnCode":0,
"extTicketID":"INC00XXXX",
"header":{
"dstApplicationID":"XXXXX-SNOW-C",
"messageID":1168XXX51,
"srcApplicationID":"XXXX-SNOWXXX-C"
},
"ticketID":"INC022XXXX"
}
}

 

Below is my code in Scripted REST API

---------------------------------------------

var requestBody = request.body.data;
var incNum1 = requestBody.XXXXX;
var status = requestBody.XXXXX;
var extTicketID = requestBody.XXXXX;
var comment = requestBody.XXXXX;
var messageID = requestBody.XXXXXX;

    var gr1 = new GlideRecord('u_XXXXXX_incident');
    gr1.initialize();
    gr1.u_source_incident_number = extTicketID;
    gr1.u_state = status;
    gr1.u_additional_comments = comment;
    gr1.u_message_id = messageID;
    gr1.u_parent_ticket_number = incNum1;
    gr1.insert();
 
 var responsedck = {
        "dack": {
        "returnCode": "0",
        "header": {
            "messageID": messageID,
            "srcApplicationID": "XXXXX-SNOW-C"
        },
        "ticketID": extTicketID
    }
    };

    var responsepck = {
      "pack":{
      "masterID":"",
      "returnCode":"0",
      "extTicketID": extTicketID,
      "header":{
         "dstApplicationID":"XXXX-SNOW-C",
         "messageID":messageID,
         "srcApplicationID":"XXXX-SNOWXXXX-C"
      },
      "ticketID": incNum1
   }
};
 
response.setBody(responsedck);
response.setBody(responsepck);
response.setStatus(200);
}
I know that response.setBody(); works for one, can anybody please help with sending both the responses as I mentioned above?
3 REPLIES 3

Pravitha
Tera Contributor

@Prasad Pagar @Ankur Bawiskar @Alikutty A Please help here if you have some insights

@Pravitha 

I think you are inserting data to staging table from scripted rest api?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Yes, I'm inserting to staging table.

 

Regards,

Pravitha