API upload pdf, filetype and name not correct in cms


#1

Hi guys,
So, third post in three days Im sorry, but I think this needs its own topic.
Long story short, Im trying to upload a new pdf file using a powershell script every night.
I wasnt able to do it with powershells own Invoke-RestMethod cmdlet, so I bit the bullet and downloaded curl for Windows. I actually managed to upload the pdf file now, but its still not really detected by the CMS in the correct way:


In the cms library folder the file saved without any ending, but I can manually open it as pdf and everything looks good!
Here is my curl command:
& $curlPath -X POST http://server/api/library -H 'Content-Type: application/x-www-form-urlencoded' -H 'Authorization: Bearer sample_access_token' -H 'cache-control: no-cache' -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' -F 'updateInLayouts=1' -F 'files=@U:\01 - Windows library\Documents\Testpdfs\2\Seite 2.pdf'
How can I fix this so the name and type is set correctly (everything works perfectly fine from postman)

I cant completely copy the code from postman, because powershell doesnt like it
TL:DR
Trying to upload a pdf through the api using curl in powershell doesnt correctly add file to library, the same call in postman works without any issues


#2

Figured it out, I was (again) just stupid and had the Content-Type in the header twice. I removed the one with www-form-urlencoded and now it seems to work!