title: How can create a case entity in Microsoft Dynamics CRM 2013 using SOAP API?
body: <p>I'm having trouble creating a Case (aka Incident) entity using the MS Dynamics CRM 2013 SOAP API.  I think I've narrowed it down to a troublesome customerid a customeridtype related reference, but haven't been able to solve it despite quite a bit of research.</p>
  
  <p>Here's the create XML I'm using:</p>
  
  <pre><code>&lt;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"&gt;
      &lt;entity&gt;
          &lt;b:attributes&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;customerid&lt;/c:key&gt;
                  &lt;c:value i:type="b:EntityReference"&gt;
                      &lt;b:id&gt;a24fb802-557d-e411-a345-6c3be5a86468&lt;/b:id&gt;
                      &lt;b:logicalname&gt;account&lt;/b:logicalname&gt;
                      &lt;b:name&gt;Testing Account&lt;/b:name&gt;
                  &lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;new_email&lt;/c:key&gt;
                  &lt;c:value i:type="d:string"&gt;test@domain.com&lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;new_phone&lt;/c:key&gt;
                  &lt;c:value i:type="d:string"&gt;111-222-3333&lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;description&lt;/c:key&gt;
                  &lt;c:value i:type="d:string"&gt;This is a test.  Please do not respond to this case.&lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;statuscode&lt;/c:key&gt;
                  &lt;c:value i:type="b:OptionSetValue"&gt;
                      &lt;b:value&gt;1&lt;/b:value&gt;
                  &lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;prioritycode&lt;/c:key&gt;
                  &lt;c:value i:type="b:OptionSetValue"&gt;
                      &lt;b:value&gt;2&lt;/b:value&gt;
                  &lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;new_date&lt;/c:key&gt;
                  &lt;c:value i:type="d:dateTime"&gt;2014-12-06T09:56:00&lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;new_cstadmin&lt;/c:key&gt;
                  &lt;c:value i:type="b:OptionSetValue"&gt;
                      &lt;b:value&gt;100000015&lt;/b:value&gt;
                  &lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;title&lt;/c:key&gt;
                  &lt;c:value i:type="d:string"&gt;Test Case by XYZ&lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
              &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;subjectid&lt;/c:key&gt;
                  &lt;c:value i:type="b:EntityReference"&gt;
                      &lt;b:id&gt;41b106d1-074a-e411-b697-9cb654957388&lt;/b:id&gt;
                  &lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
          &lt;/b:attributes&gt;
          &lt;b:logicalname&gt;incident&lt;/b:logicalname&gt;
      &lt;/entity&gt;
  &lt;/create&gt;
  </code></pre>
  
  <p>When I submit this, I get an <strong>HTTP-500</strong> back, with the error, </p>
  
  <blockquote>
    <p>You should specify a parent contact or account</p>
  </blockquote>
  
  <p>I assume that means that this chunk of xml...</p>
  
  <pre><code>            &lt;b:keyvaluepairofstringanytype&gt;
                  &lt;c:key&gt;customerid&lt;/c:key&gt;
                  &lt;c:value i:type="b:EntityReference"&gt;
                      &lt;b:id&gt;a24fb802-557d-e411-a345-6c3be5a86468&lt;/b:id&gt;
                      &lt;b:logicalname&gt;account&lt;/b:logicalname&gt;
                      &lt;b:name&gt;Testing Account&lt;/b:name&gt;
                  &lt;/c:value&gt;
              &lt;/b:keyvaluepairofstringanytype&gt;
  </code></pre>
  
  <p>...does not adequately reference the parent account for the case.  So I assume my syntax is incorrect somehow.   The reason I choose this syntax is that it reflects the same form that is returned when I RETRIEVE a case.  </p>
  
  <p>I've also tried a slightly different syntax by preparing "customerid" and "customeridtype" attributes as separate key-value pairs, such as:</p>
  
  <pre><code>        &lt;b:keyvaluepairofstringanytype&gt;
              &lt;c:key&gt;customeridtype&lt;/c:key&gt;
              &lt;c:value i:type="d:string"&gt;account&lt;/c:value&gt;
          &lt;/b:keyvaluepairofstringanytype&gt;
          &lt;b:keyvaluepairofstringanytype&gt;
              &lt;c:key&gt;customerid&lt;/c:key&gt;
              &lt;c:value i:type="b:EntityReference"&gt;
                  &lt;b:id&gt;a24fb802-557d-e411-a345-6c3be5a86468&lt;/b:id&gt;
              &lt;/c:value&gt;
          &lt;/b:keyvaluepairofstringanytype&gt;
  </code></pre>
  
  <p>...but still, no dice.</p>
  
  <p>Anyone have any ideas?</p>