Http failure response for https://cloud.exaplme.com/api/query?type=vm&format=records&type=vm&page=1&pageSize=128&filterEncoded=true&filter=(id==urn:vcloud:vm:xxxx-xxxx-xxxx-xxxx-xxxx,id==urn:vcloud:vm:xxxx-xxxx-xxxx-xxxx-xxxx) &links=true: 431 Request Header Fields Too Large
gives the correct amount of Assigned VMs
GET (131)://cloud.exaplme.com/cloudapi/1.0.0/securityTags/entities
This is a known issue in VMware Cloud Director 10.4 and 10.5
There is no solution to the issue
To update the security tags with required VMs:
1. Fetch the URN id of the VM. You can do this by clicking on the required VM in the UI. This triggers a following request:
https://{{VCD_HOST}}/api/vApp/vm-{{VM_ID}}
Response would be xml which looks like:
<Vm name="{{VM_name}}" id="{{VM_URN_ID}}" href="https://cloud.example.com/api/vApp/vm-{VM_ID}" type="application/vnd.vmware.vcloud.vm+xml">
....
</Vm>
Take the VM urn IDS of ALL the VMs that you want to assign with any security tag
2. Trigger the following CURL request
curl -X 'PUT' \
'https://cloud.example.com:8443/cloudapi/1.0.0/securityTags/tag' \
-H 'accept: */*;version=37.2' \
-H 'Authorization: Bearer {{BEARER_TOKEN}}
-H 'Content-Type: application/json' \
-d '{"tag":"{{SECURITY_TAG_NAME}}","entities":["{{ALL_URN_IDs_FETCHED_FROM_FIRST_STEP_SEPERATED_BY_COMMA}}"]}'
NOTE: It is important to append all the URN ids of VMs in same request above as it is a PUT call
Please find sample call below:
curl -X 'PUT' \
'https://cloud.example.com:8443/cloudapi/1.0.0/securityTags/tag' \
-H 'accept: */*;version=39.0' \
-H 'Authorization: Bearer {{Bearer_token}} \
-H 'Content-Type: application/json' \
-d '{"tag":"test-security-tag","entities":["urn:vcloud:vm:"{VM_ID}","urn:vcloud:vm:{VM_ID}"]}'