I have an Odata Query using a $filter with EnumType that is not working. The query is:
fpx-dev02.api.crm.dynamics.com/.../EntityDefinitions(LogicalName='opportunity')?$expand=Attributes($filter=AttributeType eq AttributeTypeCode'Virtual')
Dynamics CRM 365 returns message:
{"error":{"code":"0x0","message":"Unrecognized 'Edm.String' literal 'AttributeTypeCode'Virtual'' at '17' in 'AttributeType eq AttributeTypeCode'Virtual''.","innererror":{"message":"Unrecognized 'Edm.String' literal 'AttributeTypeCode'Virtual'' at '17' in 'AttributeType eq AttributeTypeCode'Virtual''.","type":"Microsoft.OData.ODataException","stacktrace":" at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseTypedLiteral(ExpressionLexer lexer, IEdmTypeReference targetTypeReference, String targetTypeName)\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.TryParseLiteral(ExpressionLexer lexer)\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParsePrimaryStart()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParsePrimary()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseUnary()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseMultiplicative()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseAdditive()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseComparison()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalAnd()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseLogicalOr()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpression()\r\n at Microsoft.OData.UriParser.UriQueryExpressionParser.ParseExpressionText(String expressionText)\r\n at Microsoft.OData.UriParser.ExpandOptionParser.BuildExpandTermToken(PathSegmentToken pathToken, String optionsText)\r\n at Microsoft.OData.UriParser.SelectExpandParser.ParseSingleExpandTerm()\r\n at Microsoft.OData.UriParser.SelectExpandParser.ParseCommaSeperatedExpandList(Func`2 ctor, Func`1 termParsingFunc)\r\n at Microsoft.OData.UriParser.SelectExpandSyntacticParser.Parse(String selectClause, String expandClause, IEdmStructuredType parentEntityType, ODataUriParserConfiguration configuration, ExpandToken& expandTree, SelectToken& selectTree)\r\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseSelectAndExpandImplementation(String select, String expand, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)\r\n at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseSelectAndExpand()\r\n at Microsoft.Crm.Extensibility.OData.MetadataQueryOptionsConverter.BindSelectExpand(EntityQueryExpression qe, SelectExpandQueryOption selectExpandQueryOption)\r\n at Microsoft.Crm.Extensibility.OData.QueryOptionsConverterBase`4.GetQueryExpression(ODataQueryOptions queryOptions, String edmEntityName, CrmODataExecutionContext context, XrmMetadataEntityMetadata metadata)\r\n at Microsoft.Crm.Extensibility.OData.MetadataQueryOptionsConverter.GetEntityQueryExpression(ODataQueryOptions queryOptions, String edmEntityName, CrmODataExecutionContext context, String key)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataMetadataServiceDataProvider.RetrieveEdmEntity(CrmODataExecutionContext context, String entityName, String key, ODataQueryOptions queryOptions)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.GetEntityImplementation(String& entityName, String key)\r\n at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func)\r\n at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}}}
The URL below with Namespace all fails:
fpx-dev02.api.crm.dynamics.com/.../EntityDefinitions(LogicalName='opportunity')?$expand=Attributes($filter=AttributeType eq mscrm.AttributeTypeCode'Virtual')
Used this as a reference: https://www.schaeflein.net/filter-using-enum-values-in-odata-v4/
How can this be done?