2014-12-06 59 views
0

我在使用MS Dynamics CRM 2013 SOAP API創建案例(又名事件)實體時遇到問題。我認爲我已經把它縮小到一個與定製類型有關的參考的麻煩,但是儘管進行了相當多的研究,但仍然無法解決。如何使用SOAP API在Microsoft Dynamics CRM 2013中創建案例實體?

下面是我使用的創建XML:

<create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
    <entity> 
     <b:attributes> 
      <b:keyvaluepairofstringanytype> 
       <c:key>customerid</c:key> 
       <c:value i:type="b:EntityReference"> 
        <b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id> 
        <b:logicalname>account</b:logicalname> 
        <b:name>Testing Account</b:name> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>new_email</c:key> 
       <c:value i:type="d:string">[email protected]</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>new_phone</c:key> 
       <c:value i:type="d:string">111-222-3333</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>description</c:key> 
       <c:value i:type="d:string">This is a test. Please do not respond to this case.</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>statuscode</c:key> 
       <c:value i:type="b:OptionSetValue"> 
        <b:value>1</b:value> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>prioritycode</c:key> 
       <c:value i:type="b:OptionSetValue"> 
        <b:value>2</b:value> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>new_date</c:key> 
       <c:value i:type="d:dateTime">2014-12-06T09:56:00</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>new_cstadmin</c:key> 
       <c:value i:type="b:OptionSetValue"> 
        <b:value>100000015</b:value> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>title</c:key> 
       <c:value i:type="d:string">Test Case by XYZ</c:value> 
      </b:keyvaluepairofstringanytype> 
      <b:keyvaluepairofstringanytype> 
       <c:key>subjectid</c:key> 
       <c:value i:type="b:EntityReference"> 
        <b:id>41b106d1-074a-e411-b697-9cb654957388</b:id> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 
     </b:attributes> 
     <b:logicalname>incident</b:logicalname> 
    </entity> 
</create> 

當我提出這一點,我得到一個HTTP-500回來了,錯誤,

您應該指定一個父聯繫人或帳戶

我認爲這意味着這塊xml ...

  <b:keyvaluepairofstringanytype> 
       <c:key>customerid</c:key> 
       <c:value i:type="b:EntityReference"> 
        <b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id> 
        <b:logicalname>account</b:logicalname> 
        <b:name>Testing Account</b:name> 
       </c:value> 
      </b:keyvaluepairofstringanytype> 

...沒有充分參考案例的父帳戶。所以我認爲我的語法是不正確的。我選擇這種語法的原因是,它反映了我檢索案例時返回的相同表單。

我也嘗試了稍微不同的語法通過準備「客戶ID」和「customeridtype」屬性作爲單獨的鍵值對,如:

 <b:keyvaluepairofstringanytype> 
      <c:key>customeridtype</c:key> 
      <c:value i:type="d:string">account</c:value> 
     </b:keyvaluepairofstringanytype> 
     <b:keyvaluepairofstringanytype> 
      <c:key>customerid</c:key> 
      <c:value i:type="b:EntityReference"> 
       <b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id> 
      </c:value> 
     </b:keyvaluepairofstringanytype> 

...但仍,沒有骰子。

任何人有任何想法?

+0

你是怎麼創建這個XML的? – 2014-12-07 11:23:48

+0

我正在使用雲到雲平臺服務 - itDuzzit - 將它放在一起。 – 2014-12-07 16:02:23

回答

0

AFAIK customeridcustomeridtype都應該在那裏(因爲特殊的「客戶」字段結構),所以我想嘗試的兩次嘗試混合:

<b:keyvaluepairofstringanytype> 
    <c:key>customerid</c:key> 
    <c:value i:type="b:EntityReference"> 
     <b:id>a24fb802-557d-e411-a345-6c3be5a86468</b:id> 
     <b:logicalname>account</b:logicalname> 
     <b:name>Testing Account</b:name> 
    </c:value> 
</b:keyvaluepairofstringanytype> 
<b:keyvaluepairofstringanytype> 
    <c:key>customeridtype</c:key> 
    <c:value i:type="d:string">1</c:value> 
</b:keyvaluepairofstringanytype> 

注意customeridtype包含類型代碼爲在我嘗試

<c:value i:type="d:string">1</c:value> 

這就是說,作爲一個側面說明,如果你可以把它使你的數據出來作爲JSON,你可以將其發佈到了OData服務(導致更少的痛苦經歷)號。

+0

一個很好的想法,但是我仍然遇到同樣的錯誤「當我嘗試這種技術時」您應該指定一個父級聯繫人或帳戶。「並且我同意OData服務可能更透明,但它不適合我在這一點上,不幸的是。 – 2014-12-10 14:03:31

0

Customer字段是一個非常特殊的字段,因此,而不是將一個EntityReference傳遞到該帳戶,而是嘗試傳遞一個「b:Customer」對象,看看是否有用?另外,不要浪費時間手動生成請求,對於SOAP或REST端點使用SDK工具(如Sdk.Soap.js)(要簡單得多)。

相關問題