Jump to content

Passwordstate API - add password list error


Guest Ben

Recommended Posts

' When adding a password list, the following is returned (also note that the JSON is missing a "):

[{"errors":[{"message":"Invalid API Call"},{"phrase":"Error = Object reference not set to an instance of an object.}]}]

 

I'm using Python with the requests library, posting a request to '/api/passwordlists' with the APIKey and application/json as header. The data looks as follows (and is dumped as JSON):

data = {
            'PasswordList': list_name,
            'Description': description,
            'AllowExport': False,
            'PreventDragDrop': True,
            'LinkToTemplate': False,
            'CopyPermissionsFromPasswordListID': '',
            'CopyPermissionsFromTemplateID': '',
            'NestUnderFolderID': folder_id,
            'Permission': 'M',
            'PrivatePasswordList': False,
            'ApplyPermissionsForSecurityGroupID': 'DOMAIN\\SECURITY-GROUP'
            'SiteID': 0
        }

When removing the 'Permission', and 'ApplyPermissionsForSecurityGroupID', the password list is created but the same error is returned nonetheless.

 

Any idea what could be going wrong here?

 

Link to comment
Share on other sites

Hi Ben,

I've just tested this in PowerShell and it seems to be working fine for us - see output below. I'm not sure we can help much with Python, as we have no experience with it, but I've also included my PowerShell script below so you can test. Is it possible you have missed the API Key, or are you specifying that in the Querystring - which is not recommended.

 

$PasswordstateAPIURL = "https://passwordstate.domain.com/api/passwordlists"

 

$jsonString = '
{
    "PasswordList":"My Private PL test",
    "Description":"My Private PL test",
    "AllowExport":"false",
    "PreventDragDrop":"true",
    "LinkToTemplate":"false",
    "CopyPermissionsFromPasswordListID":"",
    "CopyPermissionsFromTemplateID":"",
    "NestUnderFolderID":"9942",
    "Permission":"A",
    "PrivatePasswordList":"False",    
    "ApplyPermissionsForUserID":"halox\\msand",
    "SiteID":"0",
    "APIKey":"8e796d2b543fac8f57b23cae49d6fc58"
}
'

Invoke-Restmethod -Method POST -Uri $PasswordstateAPIURL -ContentType "application/json" -Body $jsonString

 

plcreated.png

 

Regards

Click Studios

Link to comment
Share on other sites

Hi Ben,

 

Sorry, I missed you were using a Security Group. I think the issue is you are not specifying the ID of the security group.

 

You need to lookup the ID of the group on the screen Administration -> Security Groups, as per my screenshot below.

I hope this helps.

 

secgroup.png

 

 

Regards

Click Studios

Link to comment
Share on other sites

Hi Ben,

 

Thanks for letting us know. Unfortunately we cannot do either of the two things your asking for with the API though - you do need to specify the ID for now. Possibly we could add this in a future release for you. The problem we can see is that there may be Security Groups with the same name, so a search may not be all that accurate i.e. some security groups from different domains.

Regards

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