Accept and Content-Type for "Submit record producer" api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 01:04 AM - edited 10-11-2023 01:24 AM
Hi All,
What is Accept and Content-Type for "Submit record producer" api, I am sendind csv file over this api and trying to submit the the record producer. I am using Content-Type as text/csv & not using any Accept ()
getting below error
;![CDATA[CASDK-0041: An error occurred while invoking the REST endpoint.[[Media type is null.]].The 406 Not Acceptable is an HTTP response status code indicating that the client has requested a response using Accept- headers that the server is unable to fulfill. Reiview the target service URL and try invoking the request using cURL. ]
Please share your thoughts
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 02:01 AM
what's your business requirement?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 02:12 AM
Hi Ankur,
Thank you for the reply.
The business requirement is SNOW should receive more that 40 csv files consisting 100000 records in it. And should process these files into import set table and the transform them into Target table.
Till now what we have done is we have created a record producer and and written one script there which will create a data source record with file attached to record producer and transform the data into servicenow target table . below is the script .
var transformMapSysIDs = '95aecd42976531109160f141f053af94';
current.name = gs.getUserName() + " UserImport at: " + new GlideDateTime();
current.import_set_table_name = 'u_ib_test';//Name of your import table
current.file_retrieval_method = "Attachment";
current.type = "File";
current.format = "CSV";
//current.header_row = 1;
//current.sheet_number = 1;
var sysid = current.insert();//Need this since we want to load and transform directly
gs.log(sysid+" ib");
//Now it time to load the excel file into the import table
var copyAtt = new GlideSysAttachment();
copyAtt.copy('sc_cat_item_producer', '96fb498e972531109160f141f053af9c', 'sys_data_source', sysid);
var loader = new GlideImportSetLoader();
var importSetRec = loader.getImportSetGr(current);
var ranload = loader.loadImportSetTable(importSetRec, current);
importSetRec.state = "loaded";
importSetRec.update();
//Time to run the the transform with the transform map
var transformWorker = new GlideImportSetTransformerWorker(importSetRec.sys_id, transformMapSysIDs);
transformWorker.setBackground(true);
transformWorker.start();
//To avoid to create another data source we abort the RP insert.
current.setAbortAction(true);
Manually when I attach file and then submit the record producer that time it works. Now we want to automate it so I am using submit record producer rest api to submit the created record producer but the issue is I am trying to attach csv file through this api using POST method and Content-Type as text/csv & No Acccept header >>>>>>Getting below error.
An error occurred while invoking the REST endpoint.[[Media type is null.]].The 406 Not Acceptable is an HTTP response status code indicating that the client has requested a response using Accept- headers that the server is unable to fulfill. Reiview the target service URL and try invoking the request using cURL.
