400 bad request error when attempting to delete machine prefix via api
search cancel

400 bad request error when attempting to delete machine prefix via api

book

Article ID: 314781

calendar_today

Updated On:

Products

VMware Aria Suite

Issue/Introduction

Symptoms:
Deleting a machine prefix via rest api fails with a 400 bad request error.

The /var/log/vmware/vcac/catalina.out logfile displays an error similar to:


[UTC:2019-08-16 12:44:19,913 Local:2019-08-16 12:44:19,913] vcac: [component="cafe:iaas-proxy" priority="ERROR" thread="tomcat-http--7" tenant="vsphere.local" context="CFSxB0Yz" parent="" token="CFSxB0Yz"] c
om.vmware.vcac.platform.service.rest.resolver.ApplicationExceptionHandler.handleUnexpectedException:872 - HTTP/1.1 400 Bad Request : Syntax error at position 28 in 'HostnamePrefixID eq ########-####-####-####-########3248'.Syntax error at position 28 in 'HostnamePrefixID eq ########-####-####-####-########3248'.Microsoft.Data.OData.ODataException at Microsoft.Data.OData.Query.ExpressionLexer.ValidateToken(ExpressionTokenKind t)
   at Microsoft.Data.OData.Query.UriQueryExpressionParser.ParseFilter(String filter)
   at Microsoft.Data.OData.Query.ODataUriParser.ParseFilterImpl
ementation(String filter, IEdmType elementType, IEdmEntitySet entitySet)
   at System.Data.Services.Parsing.RequestExpressionParser.ParseFilter()
org.odata4j.exceptions.BadRequestException: HTTP/1.1 400 Bad Request : Syntax error at position 28 in 'HostnamePrefixID eq ########-####-####-####-########3248'.Syntax error at position 28 in 'HostnamePrefixID eq 118714
cc-7ec5-4ed5-b14f-##########48'.Microsoft.Data.OData.ODataException at Microsoft.Data.OData.Query.ExpressionLexer.ValidateToken(ExpressionTokenKind t)
   at Microsoft.Data.OData.Query.UriQueryExpressionParser.ParseFilter(String filter)
   at Microsoft.Data.OData.Query.ODataUriParser.ParseFilterImplementation(String filter, IEdmType elementType, IEdmEntitySet
entitySet)


Environment

VMware vRealize Automation 7.x

Cause

The code should convert the machine prefix ID to a GUID before being passed to IaaS, but that does not happen, and thus we get the OData error. We perform that conversion in other API calls, so this is an inconsistency the API.

Resolution

To resolve the issue the ID part of the request can be wrapped in the OData guid syntax of guid'dddddddd-dddd-dddd-dddd-dddddddddddd'

For example, this query will allow the delete to execute successfully:

/iaas-proxy-provider/api/machine-prefixes/guid'########-####-####-####-#########59'