Regarding Rest integration import set API

Bhavana Ramesh1
Tera Contributor

Hello,

"{"error":{"message":"Invalid staging table""detail":"Specified table does not extend'sys_import_set_row'"}"status":"failure"}", The following error is populating in logs when an incident is created in source instance( I have created a Staging table extending import set row in target instance) and also i am getting the below error.

org.mozilla.javascript.EcmaError: Cannot read property "0" from undefined
Caused by error in sys_script.dc22603bdb460010fac27a61399619d8.script at line 21

18: parsedJSON=JSON.parse(responseBody);
19: var result=parsedJSON["result"];
20: gs.log("result"+ result);
==> 21: var targetTicNumber = result[0]["display_value"];
22: var targetSys_id=result[0]["sys_id"];
23: current.u_client_sysid=targetSys_id;
24: var logString = "targetTicNumber -" + targetTicNumber +"\ntargetSys_id-" +targetSys_id;( screenshot for the before insert BR is attached) and the result is showing like undefined.

 

Thanks 

Bhavana

 

1 ACCEPTED SOLUTION

Noor
Giga Contributor

Hi Bhavana,

{"error":{"message":"Invalid staging table""detail":"Specified table does not extend'sys_import_set_row'"}"status":"failure"}

for this error you can check with rest message end point as well as HTTP method end point this problem occurs when there is a mismatch in end point URL 

as you are extending the sys_import_set_row i think you are trying with import set API Please also check the end point format it should be

https://devxxxx.service-now.com/api/now/import/{stagingTableName}

Thanks,
S Noor Mohammad

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Bhavana,

Did you try to print the json response received?

Does it have that key?

Can you share the json response here?

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hello Ankur

Before parsing to json only iam getting an error, so ideally the result is undefined and i am not sure about the key in that 

 

Thanks,

Bhavana

AbhishekGardade
Giga Sage

It seems you are doing it in wrong way,

parsedJSON=JSON.parse(responseBody);

var result=parsedJSON["result"];

gs.log("result"+ result);

var targetTicNumber = result[0]["display_value"];

var targetSys_id=result[0]["sys_id"];

 

You can try on this way:

var responseBody = response.getBody();

var httpStatus = response.getStatusCode();

var obj = JSON.parse(responseBody); //define JSON parsing for the response JSON file to decode

var targetIncidentID = obj.result.sys_id;

// sys_id is key from response received , you can replace with any key in json like obj.result.number or obj.result.cmdb_ci 

// obj.result.KeyNAME : will be the same for all

gs.log("HTTPCODE:"+httpStatus+"BODY"+response.getBody());

Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade

Thank you,
Abhishek Gardade

Thank you Abhishek for the information, it was helpful:)