- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
01-09-2019 09:16 AM
Hi all,
Currently, I can't get adding a safe member to work correctly:
Invoke-RestMethod -Uri "https://XXXXXXXXX/PasswordVault/WebServices/PIMServices.svc/Safes/$IA_safename/Members" -Method Post -Body $addVaultAdmins -Headers $Headers -ContentType 'application/json'is fed with this json:
{
"member": {
"MemberName": "Vault Admins",
"SearchIn": "Vault",
"MembershipExpirationDate": "",
"Permissions": [
{
"Key": "UseAccounts",
"Value": true
},
{
"Key": "RetrieveAccounts",
"Value": true
},
{
"Key": "ListAccounts",
"Value": true
},
{
"Key": "AddAccounts",
"Value": true
},
{
"Key": "UpdateAccountContent",
"Value": true
},
{
"Key": "UpdateAccountProperties",
"Value": true
},
{
"Key": "InitiateCPMAccountManagementOperations",
"Value": true
},
{
"Key": "SpecifyNextAccountContent",
"Value": true
},
{
"Key": "RenameAccounts",
"Value": true
},
{
"Key": "DeleteAccounts",
"Value": true
},
{
"Key": "UnlockAccounts",
"Value": true
},
{
"Key": "ManageSafe",
"Value": true
},
{
"Key": "ManageSafeMembers",
"Value": true
},
{
"Key": "BackupSafe",
"Value": true
},
{
"Key": "ViewAuditLog",
"Value": true
},
{
"Key": "ViewSafeMembers",
"Value": true
},
{
"Key": "RequestAuthorizationLevel",
"Value": 2
},
{
"Key": "AccessWithoutConfirmation",
"Value": true
},
{
"Key": "CreateFolders",
"Value": true
},
{
"Key": "DeleteFolders",
"Value": true
},
{
"Key": "MoveAccountsAndFolders",
"Value": true
}
]
}
}This results in this error:
Invoke-RestMethod : {"ErrorCode":"CAWS00001E","ErrorMessage":"Failed to add User or Group Vault Admins. Reason: Input parameter for [Permissions] value is invalid."}
At file.ps1:169 char:20
+ ... DB_reply = Invoke-RestMethod -Uri "https://xxxxxx/PasswordVault/WebServ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommandDoes anyone spot the mistake that leads to "Reason: Input parameter for [Permissions] value is invalid."
Thanks & Regards,
Mat
01-10-2019 11:16 AM
There are only the standard PVWA & IIS logs.
I think I remember experiencing this issue when developing the psPAS module, but do not recall the specific resolution.
You could try to break the request down into smaller chunks to try and isolate which part of the JSON is causing issues - i.e. can all of the permissions be set individually? in groups of 2, 3, 4 etc - it might help you find the permission the API is complaining about.
01-09-2019 09:29 AM
Try to specify the permissions value als True (capital T) instead of true.
01-09-2019 11:11 AM
The body looks good. I had no issues while testing it with postman. But, i see that you're doing via PS, did you try giving the {"Key":"IPAddress", "Value": "ip"} ? It works sometimes.
01-09-2019 03:47 PM
Another thought: When you manually log in to the PVWA with the user that you use in your PS script, can you add the same permissions there? Remember... you cannot assign permissions on a safe that you yourself don't have on that safe.
01-10-2019 12:34 AM
Just tried that, didn't work unfortunately....
01-10-2019 12:36 AM
You mean by not breaking the line after the key definition? I use $var{ _json_data_} | ConvertTo-Json -Depth 3 and it automatically results in that format. I also tried using -Compress, same result.
01-10-2019 12:38 AM
It is a newly created safe from the same user I use to add this user group. All permission ticks are set, manually it just works fine.
01-10-2019 09:02 AM
Is there a good log to analyze for API errors?
01-10-2019 11:16 AM
There are only the standard PVWA & IIS logs.
I think I remember experiencing this issue when developing the psPAS module, but do not recall the specific resolution.
You could try to break the request down into smaller chunks to try and isolate which part of the JSON is causing issues - i.e. can all of the permissions be set individually? in groups of 2, 3, 4 etc - it might help you find the permission the API is complaining about.
01-11-2019 05:59 AM
solved by by your approach, typo here:
changed
{
"Key": "RequestAuthorizationLevel",
"Value": 2
},to
{
"Key": "RequestsAuthorizationLevel",
"Value": 2
},
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

