call API method SoftLayer_Virtual_Guest/setTags.json failed due to 'Invalid tag names'

北战南征 提交于 2019-12-12 05:39:05

问题


When I post https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/{vmid}/setTags.json

with params: {"parameters":["id: 899a9411-a08b-4d31-8dc6-cb2712c608dc, index: 0, job: redis-master, name: redis-master/899a9411-a08b-4d31-8dc6-cb2712c608dc, cpi-tag: redis-deployment, created_at: 2017-11-09T07:19:43Z, deployment: my-redis-deployment, director: ed-demo-director"]}

API return error with '{"error":"Invalid value provided for 'tags'. Invalid tag names: name: redis-master/899a9411-a08b-4d31-8dc6-cb2712c608dc.","code":"SoftLayer_Exception_InvalidValue"}'. As the error said, 'name' is not valid tag name. I don't know why it is invalid. And where can we set the invalid tag name list.

And did more test, I found it is due to the character '/'.


回答1:


The reason why it is invalid is because some characters like you´ve found '/', are not allowed trough the SoftLayer_Virtual_Guest::setTags method, the characters permitted are A-Z, 0-9, whitespace, _ (underscore), - (hypen), . (period), and : (colon), therefor I am afraid you won't be able to use tag names with other characters than the permitted.

Try the following REST request to make the method work, the '/' has been replaced by a hyphen '-' as it is an allowed character:

https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/35747489/setTags
method (POST)
Body (json):
{"parameters":["id: 899a9411-a08b-4d31-8dc6-cb2712c608dc,index: 0,job: redis-master,name: redis-master-899a9411-a08b-4d31-8dc6-cb2712c608dc,cpi-tag: redis-deployment,created_at: 2017-11-09T07:19:43Z,deployment: my-redis-deployment,director: ed-demo-director"]}

For more information you may see below:

https://sldn.softlayer.com/reference/services/SoftLayer_Tag/setTags

Softlayer : tagging device



来源:https://stackoverflow.com/questions/47196477/call-api-method-softlayer-virtual-guest-settags-json-failed-due-to-invalid-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!