- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2018 11:47 AM
I have a issue with upload zip file. The API Attachement /api/now/attachment/file uploaded the file to ServiceNow. After that, the content-type of this file appear like this example:
"multipart/form-data; boundary=---------------------8d5fbb014e709f7".
The problem, when I downloaded the file, I can´t open the ZIP file. Someone has the same issue or know how to resolve this problem?
Solved! Go to Solution.
- Labels:
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 07:58 PM
Hi Cesary,
There is a Youtube video on the doc site, which is handy.
https://docs.servicenow.com/bundle/london-application-development/page/integrate/inbound-rest/concept/c_AttachmentAPI.html
Two points:
1> Use Invoke-WebRequest
2> Specify content type: 'Content-Type','application/zip'
Below is the script that works in my lab:
$FilePath = "c:\asdf\a.zip"
# Eg. User name="admin", Password="admin" for this code sample.
$user = "dummy"
$pass = "asdfasdfasdfasdfasdf"
# Build auth header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass)))
# Set proper headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Authorization',('Basic {0}' -f $base64AuthInfo))
$headers.Add('Accept','application/json')
$headers.Add('Content-Type','application/zip')
# Specify endpoint uri
$uri = "https://emptwangjakarta.service-now.com/api/now/attachment/file?table_name=incident&table_sys_id=d63fb610db5697004fa76f048a9619a3&file_name=myattachment.zip"
# Specify HTTP method
$method = "post"
#{request.body ? "$body = \"" :""}}
# Send HTTP request
$response = Invoke-WebRequest -Headers $headers -Method $method -Uri $uri -InFile $FilePath
# Print response
$response.RawContent
===
If this resolves your question, please mark as answered.
Let me know if you have any further question.
Kind Regards,
Terry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 07:58 PM
Hi Cesary,
There is a Youtube video on the doc site, which is handy.
https://docs.servicenow.com/bundle/london-application-development/page/integrate/inbound-rest/concept/c_AttachmentAPI.html
Two points:
1> Use Invoke-WebRequest
2> Specify content type: 'Content-Type','application/zip'
Below is the script that works in my lab:
$FilePath = "c:\asdf\a.zip"
# Eg. User name="admin", Password="admin" for this code sample.
$user = "dummy"
$pass = "asdfasdfasdfasdfasdf"
# Build auth header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user, $pass)))
# Set proper headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Authorization',('Basic {0}' -f $base64AuthInfo))
$headers.Add('Accept','application/json')
$headers.Add('Content-Type','application/zip')
# Specify endpoint uri
$uri = "https://emptwangjakarta.service-now.com/api/now/attachment/file?table_name=incident&table_sys_id=d63fb610db5697004fa76f048a9619a3&file_name=myattachment.zip"
# Specify HTTP method
$method = "post"
#{request.body ? "$body = \"" :""}}
# Send HTTP request
$response = Invoke-WebRequest -Headers $headers -Method $method -Uri $uri -InFile $FilePath
# Print response
$response.RawContent
===
If this resolves your question, please mark as answered.
Let me know if you have any further question.
Kind Regards,
Terry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2018 07:48 AM
Terry,
It´s work very well. Thank you so much.
Best Regards