CRM 2016 oData扩展了集合

odata crm dynamics-crm-online dynamics-crm-2016 dynamics-crm-webapi

2391 观看

1回复

68 作者的声誉

我正在尝试从新的REST API检索多个数据,但遇到一个奇怪的问题。如果我在集合上使用$ expand,那么它将不起作用。

请求是:

GET [Oranization URL]/api/data/v8.0/accounts?$expand=contact_customer_accounts HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0

以及响应:

{
"error": {
    "code": "",
    "message": "Expansion of navigation properties isn\u2019t supported on entity collections.",
    "innererror": {
        "message": "Expansion of navigation properties isn\u2019t supported on entity collections.",
        "type": "Microsoft.Crm.CrmHttpException",
        "stacktrace": "   at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.ThrowIfSelectClauseHasNavigationProperty(SelectExpandClause selectExpandClause, Boolean isCalledFromEntitySet)\r\n   at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.RetrieveEdmEntityCollection(CrmODataExecutionContext context, String entityCollectionName, ODataQueryOptions queryOptions)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySetInternal(String entitySetName, String castEntityName, CrmODataExecutionContext context, CrmEdmEntityObjectCollection crmEdmEntityObjectCollection, ODataQueryOptions queryOptions)\r\n   at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySet(String entitySetName)\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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
        }
    }
}

但是,如果我在单个实体上提出此请求,那么我会得到结果

[Organization URL]/api/data/v8.0/accounts(9761dd37-d1b6-e511-80d7-001dd8b71fde)?$expand=contact_customer_accounts

在CRM的早期版本(2011,2015)中,此功能运行良好。MS是否有可能删除此功能?实际上,oData 4.0协议允许这种类型的查询

http://services.odata.org/v4/TripPinServiceRW/People?$expand=Trips

MS为什么会拒绝它?没有此功能,新的REST API将无用。

作者: zskovacs 的来源 发布者: 2016 年 1 月 12 日

回应 (1)


8

5437 作者的声誉

决定

即使我希望这会在Microsoft Dynamics CRM Web API限制中列出,但确实确实是当前实现的限制。

像您一样,其他用户已经注意到$ expand子句似乎仅在请求单个记录的数据时才起作用

我提出了一个建议,该建议是在2016年春季CRM中发布的:Web API:在collections上实现$ expand

我们在Dynamics CRM的2016年春季版本中启用了此功能。如果您请求展开并选择相关集合,则响应将包含一个带有nextlink的空集合,然后您可以使用该链接以编程方式请求每个相关页面。我们正在积极研究如何在扩展的集合中支持$ filter。如果您的情况要求这样做,那么请提出另一个想法,以便我们可以相应地对其进行优先排序。

作者: Henrik H 发布者: 12.01.2016 11:53
32x32