Santa Posted November 29, 2023 Share Posted November 29, 2023 I'm trying to upload a file to an existing password via API, using Powershell. I try to get this code to work (from Passwordstates API Manual): # PowerShell Request $documentPath = "D:\Build-Specifications.txt" $uri = "https://passwordstate/api/document/password/123?DocumentName=<DocumentName>&DocumentDescription=SomeDescription" $result = Invoke-RestMethod -Uri $uri -Method Post -InFile $documentPath -ContentType 'multipart/form-data' -Header @{ "APIKey" = "<apikey>" } Write-Host $result But I get this error message: Invoke-RestMethod: "An error has occurred., Value cannot be null.\r\nParameter name: plainText, System.ArgumentNullException Any suggestions about what that can mean? Link to comment Share on other sites More sharing options...
Santa Posted November 30, 2023 Author Share Posted November 30, 2023 . Link to comment Share on other sites More sharing options...
Mordecai Posted January 24 Share Posted January 24 Hi @Santa is the url in your example correct? "DocumentName=<DocumentName>" will not work: -> $uri = "https://passwordstate/api/document/password/210?DocumentName=SomeName&DocumentDescription=SomeDescription" you could try the Passwordstate-Management PowerShell module (or check the source code). There exists a function called New-PasswordstateDocument, this should fit your usecase. Module: PowerShell Gallery | passwordstate-management 4.4.48 Example: New-PasswordStateDocument -ID 210 -resourcetype Password -DocumentName VeryImportantScript.ps1 -DocumentDescription "very important powershell script" -Path .\Find-Item.ps1 DocumentID DocumentName ---------- ------------ 186 VeryImportantScript.ps1 Result: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now