Search code examples
ibm-cloud-infrastructure

I want to update parentID of bulk of user using SoftLayer_User_Customer::editObjects. But facing issue as below


I want to update parentID of bulk of users using SoftLayer_User_Customer::editObjects. But facing issue as below:

{ message: { error: 'The property \'parentId\' is not valid for \'SoftLayer_User_CustomerArray\'.', code: 'SoftLayer_Exception_Public' }, statusCode: 500 }

My code is in nodejs

slClient
    .auth(slUserID, slApiKey)
    .path('User_Customer', childIds, 'editObjects')
    .parameters([{"parentId":parentID}])
    .put()
    .then(res => {
        resolve(res);
    })
    .catch(err => {
        reject(err);
    });  

Here childIds is array of Softlayer IDs.


Solution

  • The SoftLayer_User_Customer::editObjects method doesn't require an InitParameter in the header, so I recommend to remove childIds in the path.

    The ID of each user you want to edit must to be in the parameters section like the sample below:

    {
        "parameters":[
            [
                {
                    "id": 1111111,         <----- user id you want to edit
                    "parentId": 6666666    <----- the new parent id
                },
                {
                    "id": 2222222,
                    "parentId": 6666666
                }
            ]
        ]
    }