Publicado Wed, 28 Feb 2024 13:00:17 GMT por Joe Spirit
Hi,

Has anyone managed to get the powershell upload via rest API to work?
Postman works fine and when taking the code for powershell and directly putting it in a console it fails.

Object reference not set to an instance of an object.NullReferenceException: Object reference not set to an instance of an object.

It looks like the code does not actually load the document. Ive tried a few ways with no luck.

I also attempted to use the -form now available in powershell 7 to create the form directly which can be seen on the microsoft documentation for multipart forms  on Invoke-restmethod(Example 5). I get the below result

Invoke-RestMethod: Value cannot be null.
Parameter name: stringToUnescapeArgumentNullException: Value cannot be null.
Parameter name: stringToUnescape


I think the problem is the [] within the form that is required for the xml upload.

I'm hoping someone else may have got this working via powershell and would be able to share how they did it.

Thanks

 
Publicado Thu, 07 Mar 2024 00:00:22 GMT por Matthias Wieland Senior Director Support EMEA
Dear Joe Spirit! It looks like the Community cannot answer your question. That's why we have opened a Support Request with the Number SR-224253-H2G4N for you. A Software Support Specialist will contact you directly to follow up. We will update this thread with the solution as soon as we have resolved the Support Request. With best regards, DocuWare Support Team
Publicado Tue, 19 Mar 2024 14:38:57 GMT por Joe Spirit

Solved - For anyone that also comes across this issue

Postman was not adding the content type of the file when parsing the code into powershell.

 Add this for the XML fields file

$fileContent.Headers.Add("Content-Type", "application/xml")

And i did this to detect the actual document mimetype and set the header

Add-Type -AssemblyName "System.Web"

$Mime = [System.Web.MimeMapping]::GetMimeMapping($File)

$fileContent.Headers.Add("Content-Type", $Mime)

You must be signed in to post in this forum.