How to upload files using REST and Powershell
95
Created On 11/10/26 10:56 AM - Last Modified 11/10/26 15:58 PM
Objective
To upload files in Powershell using CyberArk's REST API, the file must be converted to a Byte array. This can be done in Powershell through the following commands
Procedure
$File_Path = "C:\path\to\file.zip"$fileBytes = ([IO.File]::ReadAllBytes($File_Path))$restBody = @{ ImportFile=$fileBytes } | ConvertTo-JSONInvoke-RestMethod -method POST -URI "https://pvwa.server.com/passwordvaul/api/platforms/import" -ContentType "application/JSON" -header $token -body $restbodyPlatformID----------PlatformID_As_Defined_In_ZIP_Contents