c# - 如何查询所有现有字段的元数据

标签 c# .net visual-studio dynamics-crm dynamics-crm-2016

我们想让客户端能够发布到端点,例如:

    [Route("Account", Name = "CreateAccount", Order = 1)]
    [HttpPost]
    public Account CreateAccount([FromBody] Account account)
    {
        var newAccount = _accountService.CreateAccountEntity(account);
        return newAccount;
    }

我们know这可以做到:

POST [Organization URI]/api/data/v8.2/accounts HTTP/1.1
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json

{
    "name": "Sample Account",
    "creditonhold": false,
    "address1_latitude": 47.639583,
    "description": "This is the description of the sample account",
    "revenue": 5000000,
    "accountcategorycode": 1
}

我们如何向消费者公开每个发布/发布的要求?

换句话说,如果我需要使用 CRM 2016 提供的 Web API 更新自定义或基本实体上的记录,我如何知道创建或更新实体需要哪些字段?

编辑: 我尝试过 Hank 的方法,但没有返回实体的任何元数据: enter image description here

最佳答案

您可以使用 WebApi 端点查询 Dynamics 365 元数据,如 SDK 中所示.

例如,要检索account 实体的所有属性(包括要求级别):

GET [Organization URI]/api/data/v8.2/EntityDefinitions(LogicalName='account')/Attributes HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json
Content-Type: application/json; charset=utf-8

关于c# - 如何查询所有现有字段的元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43531660/

相关文章:

c# - 在 EF Code First CTP4 中构建 ObjectContext

.net - 可移植 WCF 测试客户端 10 (Visual Studio 2010)

c# - Ninject - 它被认为是一种什么样的设计模式?

c# - 如何在 C# 中加载带密码的 Excel 文件

c# - 在 C# 中获取所有枚举值的简单方法

c++ - 使应用程序在使用 Win7 功能的 WinXP/Vista 上运行

c++ - 在 visual studio 项目中为 opencv 设置包含文件依赖项

c++ - 处理非常大的多语言项目

c# - 与枚举相比,如果语句始终为真

c# - 使用 ElasticLowLevelClient 客户端在 Elasticssearch 中批量索引