Unable to attach attachment to data source table.

Vinayak Nikam
Kilo Contributor

Hi All,

Target: generate attachment through third party integration and add it into data source.

I am using below code to generate attachment through rest message and attache to data source but not getting attachment. when i am trying with incident table its working perfectly but also getResponseAttachmentSysid() returns null. 

any help appreciate.

 

//Data Source Code:

var integrationProcessGrTable="sys_data_source";
var gr1="29c4123d2f834010d0a6cc96f699b6dd";

var fileName="vuNT_.json" ;

var request = new sn_ws.RESTMessageV2('test', 'Default GET');

request.saveResponseBodyAsAttachment(integrationProcessGrTable, gr1, fileName);
response = request.execute();
httpResponseStatus = response.getStatusCode();
gs.print("Attachment sys_id :-"+response.getResponseAttachmentSysid())
gs.print(" http response status_code: " + httpResponseStatus);

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

//Incident Code

//Working but getResponseAttachmentSysid() returns null

 

var integrationProcessGrTable="incident";
var gr1="ad6f1ef12fc34010d0a6cc96f699b6b2";

var fileName="vuNT_.json" ;

var request = new sn_ws.RESTMessageV2('test', 'Default GET');

request.saveResponseBodyAsAttachment(integrationProcessGrTable, gr1, fileName); 
response = request.execute(); 
httpResponseStatus = response.getStatusCode(); 
gs.print("Attachment sys_id :-"+response.getResponseAttachmentSysid())
gs.print(" http response status_code: " + httpResponseStatus);

 

Thanks in Advance

Vinayak

6 REPLIES 6

Tony Chatfield1
Kilo Patron
Hi, sys_data_source is the table that the system stores user uploaded data import files. Have you checked/validated that you can add files manually and that there are not ACL restrictions? I am also interested in you business drivers/requirements? Why add a file to this table via integration?

Hi Tony,

 

Yes I have validated by manually and it's works. i want to add this file to process data through data source.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vinayak,

with which user profile you are using the API? Does that user has write access to the table?

I believe users with import_admin can add file to data source as attachment

Regards

Ankur

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

Hi Ankur, 

 

I am checking with admin profile. 

when i am trying for incident table (at the place of data_source) it working file getting generated and attached to record. but for any other table(i have tried with data source and custom table) it's not working.

Also i am not getting attachment sys_id.