Hi I am trying to develop an PowerShell script to delete trash files from users accounts. I have been able to get the script to get the list of users, get the first four files in the trash, but when I go to delete the files it comes back to me with an error.
What I have done:
- I have Co-Admin Auth in the system
- My app has the permissions
- The user I am trying to delete files is not an admin or co-admin
- I have tried this with the token and also using the As-user.
I continue to get two types of errors. Without the As-User I get a remote server error 404 Not Found. With the As-User I get a remote server error 403 Forbidden.
Code for deletion of files:
$uri = "https://api.box.com/2.0/files/$var2/trash"-replace(' ','')
$headers = @{"Authorization"="Bearer $token"}
Invoke-RestMethod -Uri $uri -Method Delete -Headers $headers -ContentType "applicaiton/x-www-form-urlencoded"
I am looking for help with this issue or where it is going wrong.