Automating API Calls with Powershell access_token?

Hello!

I’d like to use the API to replace some PDF files every day, I managed to do everything in postman, but now I would like to implement that into a powershell script.
The call for the access_token is already the first problem. In postman this call only works if I go to the authorization tab and then Get New Access Token (Relevant post: Postman API Tutorial -> 404 with access_token)
Doing the same thing in Powershell leaves me again with a 404 error:


With an access_token that I got from Postman, I was able to some basic calls without any issues. The second Problem is the part when I try to upload an actual file. Again, no problem in postman. How would powershell syntax look like for this? This is what I currently have:

“File type not allowed”

Is there any way of solving these issues? Should I be using a different language with postman export functionality? Is there a way of exporting from postman through the HTTP thing and using that somehow in powershell?
Thanks a lot for your help!

I used the Method get for my access_token call, changed to post still doesnt work. But I somehow got it working in postman, no idea what I changed tho
Edit: Shuffled some things around between header and body and now I get the token :slight_smile: Still the same problem with the media file upload :frowning:

You’re passing the path of the file up in a post request, but what you actually want to do is post up the actual file.

I’m not sure if you can do that with PowerShell, but a Google on the subject does seem to indicate that it is possible. You;d need to set the content type and then pass the actual file bytes somehow.