Guest Ben Posted November 6, 2017 Share Posted November 6, 2017 ' 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 More sharing options...
Ben Posted November 6, 2017 Share Posted November 6, 2017 Update: When exactly copying the Powershell example in the documentation, the error persists. Link to comment Share on other sites More sharing options...
support Posted November 6, 2017 Share Posted November 6, 2017 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 Regards Click Studios Link to comment Share on other sites More sharing options...
Ben Posted November 7, 2017 Share Posted November 7, 2017 Hi Support, Your script works for me. It seems that this is happening only when applying permissions for a security group, not for a single user. Link to comment Share on other sites More sharing options...
support Posted November 7, 2017 Share Posted November 7, 2017 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. Regards Click Studios Link to comment Share on other sites More sharing options...
Ben Posted November 8, 2017 Share Posted November 8, 2017 Hi Support, That was the issue indeed. Thanks a lot! Is there a way to pass a security group name instead? And, is it possible to retrieve a list of security groups through the API? Link to comment Share on other sites More sharing options...
support Posted November 8, 2017 Share Posted November 8, 2017 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 More sharing options...
Ben Posted November 8, 2017 Share Posted November 8, 2017 Hi Support, Makes sense. I would like to request adding/retrieving security groups by name and domain - that would be very valuable. 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