解决深度插入导航属性Dynamics WebAPI时的错误 [英] Resolve error on deep insert of navigation property Dynamics WebAPI

查看:124
本文介绍了解决深度插入导航属性Dynamics WebAPI时的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Microsoft Dynamics Web API 写入数据到Microsoft Dynamics 365中的实体.当我尝试执行

I am using the Microsoft Dynamics Web API to write data to an entity in Microsoft Dynamics 365. When I try to do a deep insert I am receiving the error

未声明的属性"ccseq_employeeid",仅在有效负载中具有属性注释,而在有效负载中未找到属性值.在OData中,只有声明的导航属性和声明的命名流可以表示为没有值的属性.

An undeclared property 'ccseq_employeeid' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.

为什么我会收到此错误?如何解决该错误?

Why am I receiving this error and how can I resolve the error?

{
    "ccseq_importdate" : "2017-05-28T04:00:00Z", 
    "ccseq_month" : "1", 
    "ccseq_year" : "2017", 
    "ccseq_name" : "Test", 
    "ccseq_status" : "100000000", "ccseq_ccseq_expensetransactionset_ccseq_expensetransaction_ExpenseTransactionSetID" : 
    [ 
        { 
          "ccseq_employeeid@odata.bind": "/systemusers(6d2fd71b-32d1-dd11-a4f5-001a6449bbe7)", 
          "ccseq_clientid@odata.bind": "/ccseq_clients(663ebd00-73b9-4faf-90ed-f56bb9c2dc9b)", 
          "ccseq_navemployeeid" : "11111", 
          "ccseq_employeefirstname" : "John"
        }
    ]
}

ExpenseTransactionSetExpenseTransaction的父级,这意味着ExpenseTransaction具有对ExpenseTransactionSet的查找. ccseq_ccseq_expensetransactionset_ccseq_expensetransaction_ExpenseTransactionSetID是一对多关系. systemuserccseq_clients是在ExpenseTransaction中进行查找的单独实体.

ExpenseTransactionSet is the parent of ExpenseTransaction meaning that ExpenseTransaction has a lookup to ExpenseTransactionSet. ccseq_ccseq_expensetransactionset_ccseq_expensetransaction_ExpenseTransactionSetID is one to many relationship. systemuser and ccseq_clients are separate entities that are lookups in ExpenseTransaction.

我还在"ccseq_employeeid@odata.bind"

  • objectid_systemuser@odata.bind
  • objectid_ccseq_employeeid@odata.bind
  • ccseq_employeeid@data.bind
  • ccseq_employeeid@odata.bind : systemusers()
  • ccseq_employeeid_systemusers@odata.bind
  • systemuserid_systemusers@odata.bind
  • objectid_systemuser@odata.bind
  • objectid_ccseq_employeeid@odata.bind
  • ccseq_employeeid@data.bind
  • ccseq_employeeid@odata.bind : systemusers()
  • ccseq_employeeid_systemusers@odata.bind
  • systemuserid_systemusers@odata.bind

我已经看到问题和这个问题,并尝试了建议的解决方案,但没有成功.

I have seen this question and this question and tried the suggested resolutions without success.

推荐答案

我发现阅读线程.深度插入中导航属性的正确语法是使用子实体名称",后跟带有字段名称的方括号. json需要更改为以下

I discovered the answer reading this thread. The correct syntax for a Navigation Property in a deep insert is to use the Child Entity Name followed by brackets with the field name. The json needs to be changed to the below

{
    "ccseq_importdate" : "2017-05-28T04:00:00Z", 
    "ccseq_month" : "1", 
    "ccseq_year" : "2017", 
    "ccseq_name" : "Test", 
    "ccseq_status" : "100000000",
    "ccseq_ccseq_expensetransactionset_ccseq_expensetransaction_ExpenseTransactionSetID" : 
    [ 
        {
          // Next two lines are changed 
          "ExpenseTransaction[ccseq_employeeid@odata.bind]": "/systemusers(6d2fd71b-32d1-dd11-a4f5-001a6449bbe7)", 
          "ExpenseTransaction[ccseq_clientid@odata.bind]": "/ccseq_clients(663ebd00-73b9-4faf-90ed-f56bb9c2dc9b)", 
          "ccseq_navemployeeid" : "11111", 
          "ccseq_employeefirstname" : "John"
        }
    ]
}

这篇关于解决深度插入导航属性Dynamics WebAPI时的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆