簡體   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