Dynamic 365 - 检索 API 元数据属性列表 - DateTimeBehavior

Dynamic 365 - Retrieve API Metadata Attribute List - DateTimeBehavior

我们已经开始使用动态 API 检索实体的属性列表以用于迁移目的,如下所示:

GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='contact')?$select=LogicalName,AttributeOf,AttributeType HTTP/1.1  
Accept: application/json  
OData-MaxVersion: 4.0  
OData-Version: 4.0  

对于“DateTime”AttributeType 字段,在其调用 DateTimeBehavior 中有一个 属性,其中有一个“仅日期”值:

"DateTimeBehavior": {
  "Value": "DateOnly"
}

我们需要知道这一点才能将遗留数据转换为 DateTime 或 Date 字段。但是,如果我们将 DateTimeBehavior 包含到我们的 GET api 调用的 $select 中,我们将得到:

{
  "error": {
    "code": "0x0",
    "message": "Could not find a property named 'DateTime' on type 'Microsoft.Dynamics.CRM.AttributeMetadata'."
  }
}

所以我们不得不对每个“DateTime”AttributeType 字段进行单独调用,以确定它是否是“DateOnly” .

有没有一种方法可以 $select 实体中的所有属性并包含此“DateOnly”字段(如果它存在)?

非常感谢任何帮助。

我不这么认为。 In order to retrieve the properties of a specific type of attribute you must cast the Attributes collection-valued navigation property to the type you want.

但是,您可以一次取回 entity/table 的所有日期时间属性及其适当的 DateTimeBehavior(相对于一次查询一个属性)。

GET /api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes/Microsoft.Dynamics.CRM.DateTimeAttributeMetadata?$select=LogicalName,DateTimeBehavior