Integration Issue key not defined

rohit_murli
Tera Contributor

 

Hello All,

We are currently working on integrating Jira with ServiceNow using a Scripted REST API.

Below is the script snippet being used:

 

 
var data = request.body.data;
gs.info("Attachment Logs: " + JSON.stringify(data)); // Log is printed
var key1 = data.issue.key;
gs.info("Issue key: " + key1); // This log is also printed with the correct issue key

Despite the logs being printed correctly, I’m receiving the following error:
"key1" is not defined.: com.glide.rest.domain.ServiceException: "key1" is not defined.:

 

Due to this error, we are unable to proceed with the integration. How to get the key value?

Thank you,

3 REPLIES 3

Nishant8
Giga Sage

Hello @rohit_murli, could you try to use 'request.body.dataString' instead of 'request.body.data'.

Also, please print the data variable and share the output.

 

Regards,

Nishant

Ankur Bawiskar
Tera Patron
Tera Patron

@rohit_murli 

sorry didn't get your exact issue

Both the logs are printed correctly and you are able to get values but still some error is coming?

Please share the complete script and what came in logs

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

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

Shruti
Mega Sage
Mega Sage
  var requestBody = request.body.data;
  var key = requestBody.issue.key;
gs.info("Issue Key" + key);