Jump to content
Meelis Nigols

Searching for folders using REST API

Recommended Posts

Another thing that was unexpected.

 

When searching folders by name, it turns out that folder name string is used for substring search.  For example, when using next URL for search: 

https://passwordstate/winapi/folders/?FolderName=Folder1&TreePath=\Test

then results include folders with following names (and treepaths):

  • Folder1 (\Test\Folder1)
  • Folder10 (\Test\Folder10)
  • Subfolder1 (\Test\Folder*\Subfolder1 - serveral folders)
  • Subfolder10 (\Test\Folder*\Subfolder10 - serveral folders)

 

How can I perform search with exact match?  Without that i have to construct desired TreePath and then compare all returned results to that, if I want to get only folder I'm searching for...

 

My PasswordState build number is 8706.

Share this post


Link to post
Share on other sites

Hi Meelis,

 

Unfortunately under these circumstances, we do not have the ability to do an exact match under a nested tree structure, so I've created this script which does a bit of data manipulation to find the exact Folder ID.  This is Powershell once again and you'll need to change your URL, and both the variables at the top of the script for your treepath and folder name. 

 

 

 

$PasswordstateUrl = "https://sandbox.halox.net"
$APIKey = "4ca37695823bdfe9285afe3bc3467d87"

 

#Set the search terms for the fodler you wish to look up in the variable below
$Name = "Folder 1"
$TreePath = "Test"

 

# Construct the URL
$FullUrl = "$PasswordstateUrl/api/folders/?FolderName=$Name&TreePath=$TreePath"

 

# Execute the search
$result = Invoke-Restmethod -Method GET -Uri $FullURL -Header @{ "APIKey" = $APIKey }

 

# Filter on Results to get FolderID
$Folder = $result  | select-object folderid, foldername | where {$_.foldername -eq "$Name"}
$FolderID = $Folder.FolderID
Write-Output $FolderID

 

 

 

 

 

Regards,

Support

Share this post


Link to post
Share on other sites
5 hours ago, support said:

 

Unfortunately under these circumstances, we do not have the ability to do an exact match under a nested tree structure, so I've created this script which does a bit of data manipulation to find the exact Folder ID.

 

 

Would it be possible to change documentation and state there, that search performs substring search?

Share this post


Link to post
Share on other sites

Hello Meelis,

 

Just letting you know that we've added Exact Match searching support for Folders and Password Lists for the next release, due by the end of the week. We'll post back again here when the new build is available.

Regards

Click Studios

Share this post


Link to post
Share on other sites

Hi Meelis,

We've just released build 8835 which includes a new exact match for the API searching on Password Lists.  If you can upgrade at your convenience, then you should be able to take advantage of this new feature.

 

Regards,

Support

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...