c# – 使用Web API在CRM数据库中添加查找GUID字段时出现错误请求错误
作者:互联网
我想在CRM的自定义实体中插入一条新记录,其中一个字段是查找类型,即new_contactid,它依赖于联系人实体.
我还提到了Set Values of all Data Types using Web API in Dynamics CRM Through C#.
我的JSON数据如下:
{
“new_transactionnumber”: “114”,
“new_transactionamount”:650,
“new_transactiondate”: “2018-01-29T15:01:00.000Z”
“new_contactid_contact@odata.bind”: “/触点(afb9e006-6be5-e711-80ed-bef806786223)”,
“new_moveid_new_move@odata.bind”: “/ new_moves(896f2dcd-b2fa-e711-80ef-bef806786223)”
}
这里,最后2个字段用于查找GUID.原始字段名称是:
> new_contactid
> new_moveid
我最后添加的是它的主键实体名称.
如果我在这里丢失任何东西,请告诉我.
编辑1:
下面是我在OData文件中找到的查找字段的引用:
<NavigationProperty Name="new_contact_new_transaction_contactid" Type="Collection(mscrm.new_transaction)" Partner="new_contactid" />
<Property Name="_new_contactid_value" Type="Edm.Guid">
<Annotation Term="Org.OData.Core.V1.Description" String="ContactId" />
<Annotation Term="Org.OData.Core.V1.Computed" Bool="true" />
<Annotation Term="Org.OData.Core.V1.Permissions">
<EnumMember>Org.OData.Core.V1.PermissionType/Read</EnumMember>
</Annotation>
</Property>
<NavigationProperty Name="new_contactid" Type="mscrm.contact" Nullable="false" Partner="new_contact_new_transaction_contactid">
<ReferentialConstraint Property="_new_contactid_value" ReferencedProperty="contactid" />
</NavigationProperty>
<NavigationPropertyBinding Path="new_contact_new_transaction_contactid" Target="new_transactions" />
<NavigationPropertyBinding Path="new_contactid" Target="contacts" />
编辑2:这些查找字段是GUID绑定到其他现有实体的主键.
解决方法:
基本上,Navigation属性将使用模式名称(Camel大小写)而不是逻辑名称(pascal大小写).
请参阅this blog post评论部分中的评论&适当改变:
Please follow the steps listed below :
Step 1 : Goto Cutomization Developer Resource.
Step 2 : Click to “Download Odata Metadata” link and Download the
same.Step 3 : Once Download, open it and find out name of lookup attribute
( i.e. “new_qualifiedleadid”) and check its casing.Step 4 : Verify it with the value which you are setting in the code it
should be same.
标签:c,dotnet-httpclient,dynamics-crm,http-status-code-400,microsoft-dynamics-webapi 来源: https://codeday.me/bug/20190627/1305075.html