Jump to content

API Create Password with $ in it


Recommended Posts



Can you fix so the whenever you use the API to create a password and the password has a $ sign in it truncates the rest of the password set in passwordstate. I proably can fix this with modifications in my script. But just wanted to have this so I wouldn't have to.


Example of a powershell script, works fine if there are no $ signs in the password. Probably the same happens with other parameters.


param($username, $password, $description)

$jsonString = @"


Invoke-RestMethod -Uri https://passwordstate.company.com/api/passwords/ -Method Post -ContentType "application/json" -Body $jsonString

Link to comment
Share on other sites

Hi Njordur,


Unfortunately we don't think we can change the API to accomodate for this, but we do have a fix for you to update your scripts.  I've given an exact example below which works, and an explanation below that of what you need to change:


# Begin Script


$jsonString = '
"Title":"company\\' + $username + '",
"Description":"' + $description + '",
"UserName":"' + $username + '",
"password":"' + $password + '",
Invoke-RestMethod -Uri https://alien.halox.net/api/passwords/ -Method Post -ContentType "application/json" -Body $jsonString


# End Script



Things I changed:

1.  The opening brackets of the JSON string   $jsonString = @"    to     $jsonString = '

2.  the variables inside the jsons string are now enclosed with a single quote and + symbol.  So we went from "UserName":"$username" to "UserName":"' + $username + '"

3. the closing brackets of the JSON went from }"@ to }'


I hope this is not too much trouble to change your scripts, and we hope this helps!




Link to comment
Share on other sites

Hi All


I'm not sure if this helps (I had no time to test it).

I usually create the JSON as following: Create a Powershell Object, then convert it to JSON.

If you do it like this, then you dont have to struggle with the string-creation.


$Body = @{
            PasswordList = $Name
            Description = $Description
            ApplyPermissionsForUserID = $global:UserToPermit
            CopySettingsFromTemplateID = $global:PasswordstateTemplateID
            LinkToTemplate = "False"
            Permission = "A"
            PrivatePasswordList = "false"
            NestUnderFolderID = $ParentFolderID
            APIKey = $global:PasswordStateSystemWideAPIKey
        $jsonBody = $Body | ConvertTo-Json

(just an example, it doesn't fit to your requirement)


Best regards,



Link to comment
Share on other sites

  • 2 weeks later...

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...