Business Applications, Common Data Service, dynamics 365, Dynamics 365 - new UI

Xrm.WebApi. “The query parameter $select is not supported” error.

Don’t be like me!

This is the JavaScript:

var uriClientLegacy = "?$select = cca_legacyservicefee, defaultpricelevelid & $filter=accountid eq " + clientLookupId;

Xrm.WebApi.retrieveMultipleRecords("account", uriClientLegacy).then( function success(result) {
...
},
function (error) {
console.log(error.message);
// handle error conditions
alert(error.message);
});

And this is the execution result:

{"error":{"code":"0x0","message":"The query parameter $select  is not supported","innererror":{"message":"The query parameter $select  is not supported","type":"Microsoft.Crm.CrmHttpException","stacktrace":"   at Microsoft.Crm.Extensibility.OData.QueryOptionsConverterBase`4.ThrowIfInvalidQueryOptionsExists(CrmODataExecutionContext context, String edmEntityName)\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.CrmODataServiceDataProvider.RetrieveEdmEntityCollection(CrmODataExecutionContext context, String entityCollectionName, String castedEntityName, ODataQueryOptions queryOptions)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySetInternal(String entitySetName, String castedEntityName, CrmODataExecutionContext context, CrmEdmEntityObjectCollection crmEdmEntityObjectCollection, ODataQueryOptions queryOptions)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySetImplementation(String entitySetName)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.<>c__DisplayClass11_0`2.<InvokeActionAndLogMetric>b__0()\r\n   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\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()"}}}

And this is the correct answer:

var uriClientLegacy = "?$select=cca_legacyservicefee,defaultpricelevelid&$filter=accountid eq " + clientLookupId; //NO WHITE SPACES!ONLY 2 WHICH ARE REQUIRED

Xrm.WebApi.retrieveMultipleRecords("account", uriClientLegacy).then( function success(result) {
...
},
function (error) {
console.log(error.message);
// handle error conditions
alert(error.message);
});

WATCH YOUR WHITESPACES! 😎

1 thought on “Xrm.WebApi. “The query parameter $select is not supported” error.”

Leave a comment