Uploading a pdf via powershell results in some jibberish

Hey guys,
Its me again! I already posted yesterday about my troubles of getting powershell to work with the API, but I managed to solve most of my issues.
My end goal is to upload and replace pdf files using powershell. Everything works, but the files arent quite right, as powershell uploads some jibberish:


This is my script so far:

It also doesnt replace the pdf with the id 23, but thats probably due to the fact that the upload isnt recognized as a pdf. Im currently updating the access_token by hand, but I will paste my already working script for that in here too.
These are the contents of the uploaded File:
updateInLayouts=1&oldMediaId=23&files=System.Byte%5B%5D
Obviously very wrong, but where is my issue? I already did a lot of general googling, but nothing really helped
Thanks a lot for your help!

I think files ought to be files[], but beyond that I believe you need to format your body for a multipart request

I did that part differently in the meantime.
I just downloaded the curl program for windows and used that in my powershell script which worked nicely!
But I will definitely try this out!

1 Like