-->

Failed to add permission to a SoftLayer user ID

2019-03-06 15:34发布

问题:

curl -D - -X POST -d @permissionSLUser.in.json -o "permissionSLUser.out.json"
"https://someuser:somepassword@api.softlayer.com/rest/v3/SoftLayer_User_Customer/1234/addPortalPermission.json"

permissionSLUser.in.json contains:

 { "parameters": [ { "key": "T_1" } ] }

permissionSLUser.out.json contains:

"error":"You may not add permissions that the parent does not possess to this account.","code":"SoftLayer_Exception_Public"

Update 1

I am certain that the parent of 1234 has T_1 permission, so I don't understand why I am getting this permission error.

Would anyone have any idea why? Thanks.

回答1:

Please use “keyname” instead of “key”.

This is a Rest Example:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_User_Customer/[user_id]/addPortalPermission

Method: POST

Json:

{
  "parameters": [
    {
      "keyName": "TICKET_VIEW"
    }
  ]
}

To get all available permissions, please review: SoftLayer_User_Customer_CustomerPermission_Permission::getAllObjects

Update 1:

If you want to use SoftLayer_User_Customer::addBulkPortalPermission, please try the following REST request:

URL:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_User_Customer/[User_Id]/addBulkPortalPermission

Method: POST

Json Payload:

{
  "parameters": [
    [
      {
        "keyName": "TICKET_VIEW"
      }
    ]
  ]
}

Note: In this case, notice that the configuration has 2 "square bracket": ...": [[{"keyName":...

I hope them help you.