Meelis Nigols Posted November 25, 2019 Share Posted November 25, 2019 I found inconsistency in REST API. Response after creating folder contains folder ID fore newly created folder, and TreePath that points to parent folder. Searching for folder return object, where both FolderId and TreePath point to found folder. Now when I want to search for Password lists in specific folder, I can refer folder by TreePath, but I can't refer folder by Folder ID. Is it intended that I will need to search for newly created folder just to get correct FolderPath reference (so that I can use it in further searches)? Or would it be possible, that creating folder response will have correct TreePath pointing to just created folder, not to parent folder? My PasswordState version is 8706. I'm unable to find API documentation on public website to check for changes in documentation after my build number. Link to comment Share on other sites More sharing options...
support Posted November 26, 2019 Share Posted November 26, 2019 Hi Meelis, If you want to use the newly created folder ID to nest a new Password List under, you could insert the Folder ID into a variable that can be later used in your script. Here is a Powershell version of this of creating a Folder, and then adding in a Password List under that folder $PasswordstateUrl = "https://sandbox.halox.net" $APIKey = "4ca37695823bdfe9285afe3bc3467d87" # Define values for the Folder $Body = @{ FolderName = "Folder 1" Description = "First API Folder" NestUnderFolderID = "0" APIKey = $APIKey Guide = "This is some test text to be inserted into the guide for this Folder" PropagatePermissions = "Fals" CopyPermissionsFromTemplateID = "31" } # Convert Array to Json $jsonData = $Body | ConvertTo-Json # Execute the command $FullUrl = "$PasswordstateUrl/api/folders" $result = Invoke-Restmethod -Method Post -Uri $FullUrl -ContentType "application/json; charset=utf-8" -Body $jsonData $FolderID = $result.FolderID Write-Host $FolderID # Define values for the Password List in below array $Body = @{ PasswordList = "A New Password List" Description = "This short description is for my Test Password List" NestUnderFolderID = $FolderID APIKey = $APIKey Guide = "This is some test text to be inserted into the guide for this Password List" ImageFileName = "activedirectory.png" AllowExport = "True" PrivatePasswordList = "False" PasswordGeneratorID = "117" PreventBadPasswordUse = "true" PasswordResetEnabled = "true" CopyPermissionsFromTemplateID = "31" } # Convert Array to Json $jsonData = $Body | ConvertTo-Json # Execute the command $FullUrl = "$PasswordstateUrl/api/passwordlists" $result = Invoke-Restmethod -Method Post -Uri $FullUrl -ContentType "application/json; charset=utf-8" -Body $jsonData Hopefully this helps and I'll also answer your second forum post about searching for folders. Regards, Support Link to comment Share on other sites More sharing options...
Meelis Nigols Posted November 26, 2019 Author Share Posted November 26, 2019 I am creating folder/password list structure with a script. So i create folder if they don't exist. But if folder already exists, i need find, if next level folder/password list exists. And it is not possible to search folder/password list based on Folder ID. I have to use TreePath. And that brings me back to TreePath. The Create Folder command gets back response with newly created Folder ID, but with parent folder TreePath. when I create folder like this: $jsonData = @{ "FolderName":"Test Folder", "Description":"First API Folder", "NestUnderFolderID":"48" } | ConvertTo-Json $PasswordstateUrl = 'https://passwordstate/winapi/folders' $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentials I will get back response like this: HTTP/1.1 200 [ { "FolderID": 181, "FolderName": "Test Folder", "Description": "First API Folder", "TreePath": "\parentfolder" } ] and the TreePath is not containing newly created folder name. I would suggest to change the response so, that newly created Folder Treepath (instead of parent folder TreePath) will be returned. Is it possible? Meelis Link to comment Share on other sites More sharing options...
Meelis Nigols Posted November 29, 2019 Author Share Posted November 29, 2019 On 11/26/2019 at 8:43 AM, Meelis Nigols said: I would suggest to change the response so, that newly created Folder Treepath (instead of parent folder TreePath) will be returned. Is it possible? or if changing response is not possible, then at least add to documentation statement, that parent path is returned as TreePath Meelis Link to comment Share on other sites More sharing options...
support Posted November 29, 2019 Share Posted November 29, 2019 Hello Meelis, The TreePath field only represents the parent tree path, and not the current folder name that has just been created. Would combining searches help at all i.e. TreePath and Folder name, or TreePath and Password List name? This can be done in the following format, as an example ?FolderName=<value>&TreePath=<value>. I would suggest upgrading to build 8835 before trying this though, as we made a slight change when searching TreePath. Sorry if our documentation did not have this level or detail. Regards Click Studios 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