繁体   English   中英

Microsoft Dynamics CRM 2015-使用OData API创建实体

[英]Microsoft Dynamics CRM 2015 - Creating Entity using OData API

不确定为什么以下请求会出现以下错误:

处理请求流时出错。 该请求应该是有效的顶级资源对象。

要求(由于明显的原因,某些细节被混淆了):

POST http://someUrl.com/someUrl/XRMServices/2011/OrganizationData.svc/someSet HTTP/1.1
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8
Accept-Encoding: gzip, deflate
Content-Length: 387
Host: someUrl.com

{
    "paymentid": {
        "Id": "00e3f661-8d28-e321-896e-00155dfd1d05",
        "LogicalName": "payment"
    },
    "invoiceid": {
        "Id": "00e3f661-8d28-e411-896e-00155dfd1d05",
        "LogicalName": "invoice"
    },
    "AppliedAmount": 1317.53000,
    "name": "Payment Applied",
    "postingstatus": "Posted",
    "transactioncurrencyid": {
        "Id": "80870a9b-329e-d421-8a22-00155d025001",
        "LogicalName": "transactionCurrency"
    }
}

所有逻辑名称均来自运行以下查询:

select
    LogicalName
from 
    NHLPA_MSCRM.dbo.EntityView
where
    BaseTableName = 'paymentbase' -- | invoicebase | transactioncurrencybase

摘要:使用OrganizationData.svc/someSet URL获取现有实体的列表,为必要的JSON结构(减去_metaData属性)提供了完美的参考。

因此,问题最终变得非常简单。

实体someSet并不是问题,可以通过无问题访问http://someUrl.com/someUrl/XRMServices/2011/OrganizationData‌​.svc/someSet来表示。

深入了解内部逻辑实体(付款,发票,交易货币)。 如前所述,这些逻辑名来自数据库,与实体设置页面匹配(下图)。

在此处输入图片说明

但是,以下所有URL均无法解析:

  • http://someUrl.com/someUrl/XRMServices/2011/OrganizationData‌​.svc/paymentSet
  • http://someUrl.com/someUrl/XRMServices/2011/OrganizationData‌​.svc/invoiceSet
  • http://someUrl.com/someUrl/XRMServices/2011/OrganizationData‌​.svc/transactionCurrencySet

问题是,尽管在所有可以找到实体逻辑名称的地方都是小写字母 ,但实际上第一个字母必须大写,例如:

  • http://someUrl.com/someUrl/XRMServices/2011/OrganizationData‌​.svc/PaymentSet
  • http://someUrl.com/someUrl/XRMServices/2011/OrganizationData‌​.svc/InvoiceSet
  • http://someUrl.com/someUrl/XRMServices/2011/OrganizationData‌​.svc/TransactionCurrencySet

和有效载荷:

{
    "paymentid": {
        "Id": "00e3f661-8d28-e321-896e-00155dfd1d05",
        "LogicalName": "Payment"
    },
    "invoiceid": {
        "Id": "00e3f661-8d28-e411-896e-00155dfd1d05",
        "LogicalName": "Invoice"
    },
    "AppliedAmount": 1317.53000,
    "name": "Payment Applied",
    "postingstatus": "Posted",
    "TransactionCurrencyId": {
        "Id": "80870a9b-329e-d421-8a22-00155d025001",
        "LogicalName": "TransactionCurrency"
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM