- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2018 01:22 PM
I see this question has been asked several times and I see a recommendation of using an app from ServiceNow guru / Servicenow share / crossfuze solution. Most of the recommendations were dated 2 years ago.
Anything changed in ServiceNow where it's straightforward to import data from Mid Server? Greatly appreciate if someone can give pointers on best approach to do it without much custom coding.
Thank you,
Krishna
Solved! Go to Solution.
- Labels:
-
Scoped App Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2018 06:23 AM
Hi Krishna,
Instead of writing the files to the MID Server host, it will probably be easier to have your 3rd party application write the file directly to the instance.
You can either send it as an import set to the instance with the following endpoint URL:
https://<instance>.service-now.com/sys_import.do?sysparm_import_set_tablename=<import_table_name>&sysparm_transform_after_load=true&uploadfile=<path>.csv
More information on this method can be found here:
Alternatively, you can have the file attached to an existing record, such as an incident, by using Attachment API
If that's not an option and you need to pull from the MID Server host, you can take advantage of the MID Server command probe. This allows you to run shell commands on the system. What this would look like is:
var probe = SncProbe.get("Command");
probe.setName("cd /Users/me/Desktop && cat example.csv | base64");
probe.create("<MID Server Name>");
The response to this will be a base64 encoded string of the file that will get written to ECC Queue in the response. You can then turn this into an attachment with a script on the instance
var encStr = '<long base64 encoded string>';
var stringUtil = GlideStringUtil;
var attachment = new Attachment();
attachment.write('<table>', '<record sys_id>', '<file name>', 'text/csv', stringUtil.base64DecodeAsBytes(encStr));
I'm sure there's a better approach than that, but hopefully that gives you some ideas to work with. Best of luck!
-Brian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2018 06:23 AM
Hi Krishna,
Instead of writing the files to the MID Server host, it will probably be easier to have your 3rd party application write the file directly to the instance.
You can either send it as an import set to the instance with the following endpoint URL:
https://<instance>.service-now.com/sys_import.do?sysparm_import_set_tablename=<import_table_name>&sysparm_transform_after_load=true&uploadfile=<path>.csv
More information on this method can be found here:
Alternatively, you can have the file attached to an existing record, such as an incident, by using Attachment API
If that's not an option and you need to pull from the MID Server host, you can take advantage of the MID Server command probe. This allows you to run shell commands on the system. What this would look like is:
var probe = SncProbe.get("Command");
probe.setName("cd /Users/me/Desktop && cat example.csv | base64");
probe.create("<MID Server Name>");
The response to this will be a base64 encoded string of the file that will get written to ECC Queue in the response. You can then turn this into an attachment with a script on the instance
var encStr = '<long base64 encoded string>';
var stringUtil = GlideStringUtil;
var attachment = new Attachment();
attachment.write('<table>', '<record sys_id>', '<file name>', 'text/csv', stringUtil.base64DecodeAsBytes(encStr));
I'm sure there's a better approach than that, but hopefully that gives you some ideas to work with. Best of luck!
-Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2020 07:48 PM
When trying to use "https://<instance>.service-now.com/sys_import.do?sysparm_import_set_tablename=<import_table_name>&sysparm_transform_after_load=true&uploadfile=<path>.csv"
I am also facing the issue "sorry an error occurred on this page isn't available". Did you manage to find out why this happened?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2020 03:02 AM
I have given the below roles to the user - import_set_loader and import_set_admin. However when i do a post from Post to below URL i get an error "Sorry, an error occurred or this page isn't available"
1. https://<instancename>.service-now.com/sys_import.do?sysparm_import_set_tablename=u_service_now_user_report&sysparm_transform_after_load=true&uploadfile=D:\service_now_user_report.csv
2. https://<instancename>.service-now.com/sys_import.do?sysparm_import_set_tablename=u_service_now_user_report&sysparm_transform_after_load=true
Is there a step I am missed to enable the use of this method to import the data?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 07:32 AM
Where do I have to write this code?
var probe = SncProbe.get("Command");
probe.setName("cd /Users/me/Desktop && cat example.csv | base64");
probe.create("<MID Server Name>");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2018 07:33 AM
Great thoughts Brian. It was a good insight into how we can post csv files from java program. I'll ask the source team to check the feasibility on this.
On the other note, Today I was able to work through the "Remote File Import" service that helped for direct csv imports. Had to change couple of lines of code on the Mid-server script include and it worked. Also, had to run the remote file import with mid_server and admin credentials.
Thanks,
Krishna