Jump to content

Documents API

Recommended Posts



How to identify what type of file I get as a response when I use the /api/document/passwordlist/<DocumentID> API. 


I get the response, and if I already know the file type, and save it, it works, but if i do not know the file type, then I dont know how to save it. 

Can i append something to the header to get the filename and description somehow? 


I use this in Powershell: 
Invoke-Restmethod -Method GET -Uri $PasswordstateUrl -Header @{ "APIKey" = "$Apikey" } -OutFile myfile.abc


Thank you. 

Link to comment
Share on other sites

Hi Johan,


What you've pointed out is a good point if you do not know the document name. I think we'll need to add another method to the API to retreieve the document name separately, but below is how you can do it for the moment - update the filename path as appropriate, and IDs and API Key.


$PasswordstateUrl = '/api/document/password/<DocumentID>'

#Read and output key to file
$result = Invoke-WebRequest -Method GET -Uri $PasswordstateUrl -Header @{ "APIKey" = "$Apikey" }
$contentDisposition = $result.Headers.'Content-Disposition'
$fileName = $contentDisposition.Split("=")[1].Replace("`"", "")
$fileName = Join-Path "c:\temp" $fileName

Invoke-WebRequest -Method GET -Uri $PasswordstateUrl -Header @{ "APIKey" = "$Apikey" } -OutFile $filename



Click Studios

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...