- 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
‎09-12-2019 04:15 PM
I face same issue getting error message as "HTTP Status 400 – Attachment could not be successfully extracted". did any one had solution in place?
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2019 06:57 AM
Hi,
Provide the user "import_admin" role and try
Thanks & Regards,
Vasanth

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2020 11:26 PM
did this work ?, i get message "sorry an error occurred on this page isn't available".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2020 07:48 PM
I am also facing the same 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
‎04-21-2021 02:49 PM
I am sorry - I see this one is really old post, but I come in with the same problem, which is really working in dev/test instances but does not in PROD.
Here is steps: separated PowerShall driven process is creating CSV file and save it in MID c:\temp
Then another action uses REST API:
Invoke-WebRequest -Headers $headers -Method POST -Uri $uri -InFile "$file_path" -UseBasicParsing
to attach it to RITM.
Where:
$file_path = "C:\Temp\fileToAttach.csv"
$file_name = "fileToAttach.csv";
$uri = "https://${sn_env}.service-now.com/api/now/attachment/file?table_name=sc_req_item&table_sys_id=${item_sys_id}&file_name=${file_name}";
We defined ID with rest_services and itil roles to be used in API call.
As I said: in DEV/TEST instances it working as a charm, but in prod it shows error:
Invoke-WebRequest : Access to the path 'C:\Temp\fileToAttach.csv' is denied.
FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I understand the access issue, but did not see what is missing. Access to c:temp in MID for that ID is the same as in DEV/TEST....
Any ideas?