Jump to content

Create Passwordlists with API fails


Recommended Posts

Hi, 

 

When trying to create a passwordlist I get an error (this is just a minimalistic query):


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

The error I get is following:


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

I tried several options, taken from your documentation, but can't see what I'm missing. Creation of passwords with the same URL (only "password" instead of "passwordlist") works as expected. 

 

I'm using build 7476.

 

Regards

Stefan Pahrmann

 

Link to post
Share on other sites

Hi Stefan,

 

When creating Password Lists, there are additional fields required i.e. what Password List or Template to copy settings from, or what Password List or Template to copy permissions from. Below is an example of a curl request and PowerShell request - can you let me know if this helps at all?

 

# curl Request
    curl --request POST https://passwordstate/api/passwordlists
       -d "PasswordList=Windows Servers" \
       -d "Description=Local Admin accounts for all Windows Servers" \
       -d "CopySettingsFromPasswordListID = 34" \
       -d "CopySettingsFromTemplateID = " \
       -d "LinkToTemplate = false" \
       -d "CopyPermissionsFromPasswordListID = 34" \
       -d "CopyPermissionsFromTemplateID = " \
       -d "NestUnderFolderID = 128" \
       -d "apikey=b2a57c34fe96d8f36a89c25eb47d4b6c"
 
# Powershell Request
#JSON data for the new Password List
    $jsonPasswordList = '
    {
   "PasswordList":"Windows S2012",
   "Description":"Windows Servers 2012",
   "CopySettingsFromPasswordListID":"183",
   "CopySettingsFromTemplateID":"",
   "LinkToTemplate":false,
   "CopyPermissionsFromPasswordListID":"4",
   "CopyPermissionsFromTemplateID":"",
   "NestUnderFolderID":"0",
   "APIKey":"b2a57c34fe96d8f36a89c25eb47d4b6c"
    }
    '
 
    $result = Invoke-Restmethod -Method Post -Uri https://passwordstate/api/passwordlists -ContentType "application/json" -Body $jsonPasswordList
 
Regards
Click Studios
Link to post
Share on other sites

Hi Stefan,

 

The minimum requirements are:

  • PasswordList
  • APIKey
  • CopySettingsFromPasswordListID or CopySettingsFromTemplateID
  • CopyPermissionsFromPasswordListID or CopyPermissionsFromTemplateID

Below is the minimalist call you can make - this is the json data for a PowerShell call:

 

$jsonPasswordList = '
{
"PasswordList":"Test Password List",
"CopySettingsFromPasswordListID":"183",
"CopyPermissionsFromPasswordListID":"183",
"APIKey":"8e796d2b543fac8f57b23cae49d6fc58"
}
'
 
I've just tested this and it seems to be working fine, so please let me know if you have any more issues with this.
 
Regards
Click Studios
Link to post
Share on other sites

Hi again,

 

just tried that, same error (see output, I have a screenshot as well). Passwords in lists can be created and passwords can be generated. Any logfiles to look into or some hints on how to debug?


curl -k --request POST https://webserver:9119/api/passwordswordlists -d "PasswordList=ZZZ3-Test" -d "CopyPermissions   FromTemplateID=1" -d "CopySettingsFromTemplateID=1" -d "APIKey=xxxxxxxx"

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

curl -k --request POST https://webserver:9119/api/passwordswordlists -d "PasswordList=ZZZ3-Test" -d "CopyPermissions   FromTemplateID=1" -d "CopySettingsFromTemplateID=1" -d "APIKey=xxxxxxxx"

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

Both PasswordListID and TemplateID do exists. 

 

-Stefan

Link to post
Share on other sites

Hi Stefan,

 

It may just be formatting in our forum "CopyPermissions FromPaswordListID=6" doesn't look right - there should be no spaces in this field name. Also, are you using the System Wide API Key for this?

 

Also, the URL should be https://webserver:9119/api/passwordwordlists - you had an extra S in PasswordLists (sorry I didn't pick up on this earlier).

 

If this doesn't help we will need to organise a remote desktop session with you to try and help troubleshoot this further.

 

Regards

Click Studios

Link to post
Share on other sites

Awesome - thanks Stefan, and my eyesight is not better than yours :)

 

We're also working on plenty of PowerShell script examples at the moment, and we will add them to a section in the Help menu so customers can simply cut and paste into their own environment - assuming their using PowerShell of course.

 

Regards

Click Studios

Link to post
Share on other sites
  • 1 year later...

Hi, I think I have a similar problem. I try to add password list via API (v7.7 build 7789) using ApplyPermissionsForSecurityGroupID and Permission parameters (I don't want to copy permission from another list, I just want to use one security group). When I send the following data (using Ansible):


      PasswordList: "{{ tenant }}"

      Description: "{{ tenant }} passwords list"

      CopySettingsFromPasswordListID: 1079

      CopySettingsFromTemplateID: ""

      LinkToTemplate: false

      CopyPermissionsFromPasswordListID: ""

      CopyPermissionsFromTemplateID: ""

      NestUnderFolderID: 1070

      ApplyPermissionsForSecurityGroupID: adgroup

      Permission: M

      apikey: "{{ passwords_apikey }}"

I got Object reference not set to an instance of an object. (As explained above CopyPermissionsFromPasswordListID or CopyPermissionsFromTemplateID  are mandatory.)

When I change to the following (CopyPermissionsFromPasswordListID added):


      PasswordList: "{{ tenant }}"

      Description: "{{ tenant }} passwords list"

      CopySettingsFromPasswordListID: 1079

      CopySettingsFromTemplateID: ""

      LinkToTemplate: false

      CopyPermissionsFromPasswordListID: 1079

      CopyPermissionsFromTemplateID: ""

      NestUnderFolderID: 1070

      ApplyPermissionsForSecurityGroupID: adgroup

      Permission: M

      apikey: "{{ passwords_apikey }}"

I got


When specifying explicitly specifying permissions to be added for the Password List, you cannot copy permissions from another Password List or Template - omit or leave the paramaters blank

Could you please explain how to use ApplyPermissionsForSecurityGroupID and Permission parameters?

Link to post
Share on other sites

Hi pawkor,

 

I can't be sure, but I think I can see the issue:

  • Can you remove the lines CopyPermissionsFromPasswordListID and CopyPermissionsFromTemplateID
  • And for the ApplyPermissionsForSecurityGroupID, this needs to be the ID of the Security Group, not the name. You can look up the ID's on the screen Administration -> Security Groups

Regards
Click Studios 

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