bulk upload of attachments using powershell REST API

manukundur
Giga Contributor

Hi All,

I am using a power shell script for bulk uploading attachments from below community thread.

 

https://community.servicenow.com/community?id=community_article&sys_id=df3caa61dbd0dbc01dcaf3231f9619aa

 

 

However, I see that the Power Shell is using a SOAP based call and therefore, we are not able to upload attachments more than 4 MB. This is the SOAP limitation.

I would like to convert the SOAP based call to REST based call. Can someone share the code for the REST API call please?

 

 

 

 

1 REPLY 1

andrew_venables
ServiceNow Employee
ServiceNow Employee

Hi manukundur,

THe platform can help you create part of the Powershell script, as follows:

On your instance navigate to "REST API Explorer" on the left hand side.

The explorer will open and you can select the following:

Namespace: now

API Name: Attachment API

API Version: latest

Then select from the list: "Upload an attachment from a binary request (POST)"

This will load the API for uploading attachments into the window. 

You can then configure the following query parameters:

table_name:  incident

table_sys_id: <sys_id of an example incident>

file_name: <example file name>

Then if you scroll all the way to the bottom of the page in the bottom right hand corner you should see a link named: [Powershell]

find_real_file.png

This will generate a sample Powershell script for integrating with the REST API on your instance.

You can then integrate this script into your code without the 4mb restriction.