Softlayer : tagging device

2019-03-01 14:24发布

I couldn't find any option to Tag a device while creating the device in Customer portal, so I am Using SoftLayer_Tag::setTags Rest API to tag a device:

POST: https://Username:API_KEY@api.softlayer.com/rest/v3/SoftLayer_Tag/setTags.json
BODY: 
resourceTableId : 29756959
keyName : march22

But getting error saying:

{ "error": "You do not have permissions to tag this object.",
"code": "SoftLayer_Exception_PermissionDenied" }

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-03-01 14:54

There is a mistake in the way that you are sending the body(tags parameter is missing and there is a wrong value for keyName), try this:

Virtual Guests

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Tag/setTags

Method: Post

{  
   "parameters":[  
      "tag1,tag2",
      "GUEST",
      29756959
   ]
}

Hardware

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Tag/setTags

Method: Post

{  
   "parameters":[  
      "tag1,tag2",
      "HARDWARE",
      29756959
   ]
}

Updated

To set tags you need to check the following:

  1. Access to device
  2. Permission enabled for Device Type (Vsi/Hardware):

    • Hardware -> View Hardware Details
    • VSI -> View Virtual Server Details

There is no way to set tags at the moment to place the order, you can set them after submit the order

Devices >> Device List >> Search the device (e.g: rcvtagtest)

enter image description here

Another way would be to place the order through API, in which it's possible to set tags through it at the moment to create the server, here an example for VSI:


Updated2


The SoftLayer_Tag::getTagByTagName method provides information about the tag, not the devices which have being tagged with this.

It will provide information from the tag based on tag name, so it's not necessary to send an identifier, so the correct way for this is:

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Tag/getTagByTagName

Method: Post

{  
   "parameters":[  
      "test1,test2"
   ]
}

Replace: $user, $apiKey with you own information and test1 and test2 with the tag names that you would like to retrieve

In case that you would like to retrieve devices, take a look this forum(for Vsis, the same idea should be applied for BMS):

If this doesn't help you, please provide more information about your requirements, in order that I can help you

查看更多
登录 后发表回答