Using PowerShell and the Attachment API and getting error "Expected end of stream at char 4747"

DrewW
Mega Sage
Mega Sage

We have files being output by a scanner.  Those files have to be attached to records in ServiceNow.  The only way we could do it was to use PowerShell and the Attachment API to create the record then attach the files.  The issue we are having is that occasionally they scan a document that has a lot of pages and is over 500mb and when that happens the script errors with this message

 

Error: Expected end of stream at char 4747,Detail: Expected end of stream at char 4747

 

It only happens when the file is over 500mb and all of the attachment settings are set to except files well over that size.  Also I can login to the ServiceNow and create a record and then manually attach the file myself and it works just fine.  I have looked at zipping the file but the amount it compresses is not sufficient to get the size below this 500mb limit.  I also know that PowerShell has a 500mb limit on XML files so I'm assuming this is some kind of limit in PowerShell and not ServiceNow.

 

Has anyone had this issue and if so did you find a way to fix the issue?

0 REPLIES 0