"431 request header fields too large" error when editing Networking Security Tag assigned to more than 100 VMs
search cancel

"431 request header fields too large" error when editing Networking Security Tag assigned to more than 100 VMs

book

Article ID: 370392

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

  • VM Security tag has been assigned to more than 100 VMs

  • When browsing the Networking Security Tag on CD UI, you get an error like the one reported below with long string of VM IDs:
    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

  • The output of the below API run from Postman or API Explorer gives the correct amount of Assigned VMs
    GET (131)://cloud.exaplme.com/cloudapi/1.0.0/securityTags/entities

Environment

  • VMware Cloud Director 10.4
  • VMware Cloud Director 10.5

Cause

This is a known issue in VMware Cloud Director 10.4 and 10.5

Resolution

There is no solution to the issue

Workaround

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}"]}'