2013-07-05 54 views
2

更新:Here is the marketing list entity metadata。向下滾動,您可以看到多對多關係,您可以看到我嘗試使用的listcontact_association。使用休息創建實體關聯

我在嘗試將聯繫人與營銷列表關聯。這是我想使用(基本上POST與URI一個json):

curl --ntlm -u username:password -X POST -H "Content-Type: application/json" -d '{"uri":"http://hostname/XRMServices/2011/OrganizationData.svc/ContactSet%28guid%27<guid>%27%29"}' 'http://hostname/XRMServices/2011/OrganizationData.svc/ListSet%28guid%27<guid>%27%29/$links/listcontact_association' 

這就是我從CRM接收:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> 
    <code>-2147220989</code> 
    <message xml:lang="fi-FI">Invalid role specified for entity 'list'in relationship 'listcontact_association.Referenced'</message> 
    <innererror> 
    <message>Invalid role specified for entity 'list'in relationship 'listcontact_association.Referenced'</message> 
    <type>System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=<token>]]</type> 
    <stacktrace> at Microsoft.Crm.Extensibility.OrganizationDataServiceUpdateProvider.System.Data.Services.IUpdatable.SaveChanges()&#xD; 
    at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)&#xD; 
    at System.Data.Services.DataService`1.HandleRequest()</stacktrace> 
    </innererror> 
</error> 

如果我刪除了$links部分,我得到一個不同的錯誤:

<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> 
    <code></code> 
    <message xml:lang="fi-FI">Error processing request stream. The property name 'URI' specified for type 'Microsoft.Crm.Sdk.Data.Services.List' is not valid.</message> 

這將導致我相信有一些我應該嘗試關聯該人的其他關係,但是我無法訪問CRM以查找此信息,並且文檔不是非常有用:(任何線索?

回答

0

我仍然不知道這是通過REST端點是可行的。我們發現了SOAP端點提供了REST端點不具備的功能的情況,這可能就是這種情況。

我所做的就是改用SOAP端點。沒有內置的方法,所以我不得不使用一般的方法。在這種情況下,這是一個組織請求,我在其中請求了名爲「AddMemberList」的請求。

0

您能否使用列出的SDK調用here

有例如使用SDK.REST.associateRecords功能:

SDK.REST.associateRecords(parentAccount.AccountId, 
    "Account", 
    "Referencedaccount_parent_account", 
    childAccount.AccountId, 
    "Account"); 
+0

從我可以告訴,上面的curl命令完成相同的功能:/ – Zavior

+0

它可能,我從來沒有使用過。 – Daryl