"Posting CSV or Excel Files Directly to an Import Set": how to set charset?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2014 03:36 AM
Hi all,
I'm facing an issue while posting CSV directly to an Import set setting charset for special character handling. It is working fine if the CSV does not contain any special character. I've gone through the URL (http://wiki.servicenow.com/index.php?title=Importing_Data_Using_Import_Sets#Posting_CSV_or_Excel_Fil...) for posting CSV directly to an Import set. Special character handling is working if I do it manually by Loading to a newly created Data Source where i set the Property field value as "charset=utf-8". This is mentioned in URL (http://wiki.servicenow.com/index.php?title=Data_Sources#Encoding). I need to know how to set the character-set so that it handles the special chracter after direct CSV file posting to Import Set. Below java code I have used.
String url = "https://dev.service-now.com/sys_import.do?sysparm_import_set_tablename=table_name&sysparm_transform_...;
PostMethod post = new PostMethod(url); |
try { |
HttpClient httpclient = new HttpClient(); |
Credentials defaultcreds = new UsernamePasswordCredentials(usrName , usrPwd); |
// Prepare HTTP post | |||
httpclient.getState().setCredentials(AuthScope.ANY, defaultcreds); |
File targetFile = new File(transferFile); | ||
FilePart filePart = new FilePart(targetFile.getName(), targetFile, "application/octet-stream", "utf-8"); | ||
//filePart.setCharSet("utf-8"); |
Part[] parts = {filePart}; |
post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams())); | ||
int result = httpclient.executeMethod(post); |
}
Though i've set charset during posting but it has no impact. Could you please give me some ideas how i can achieve this? And what are the other parameters I can pass in the URL other than sysparm_import_set_tablename, sysparm_transform_after_load and uploadFile? Please let me know if you need further information.
Thanks,
San
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2014 04:54 AM
Hi Guys,
I found a work around for this requirement. Condition is that the csv file name has to be same always. By default SN create data source with the file's name + (Uploaded) and continue using that same DS as long as the file name is same. So if we change the Properties filed value for that DS then it would work as i expected.
Thanks,
Sanoajul.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2016 11:03 PM
Hi,
I created a before insert business rule on Data source table since my filename will change every week. This rule will set properties to "charset=utf-8", whenever a new data source is created. This will work only if a certain part of filename remains constant.
Thanks,
Vikas.