2016-04-15 9 views
0

そのAPIを使用してDynamics CRMにインシデントを作成しようとしています。Dynamics CRMのインシデントを作成します

イム私が使用してインシデントを作成しようとすると、正常しかしauthing:

You should specify a parent contact or account.-2147204080 You should specify a parent contact or account.2016-04-15T07:59:11.6607106Z-2147204080 You should specify a parent contact or account.2016-04-15T07:59:11.6607106Z

任意のアイデア私は何が欠けている:

$accountsRequest = EntityUtils::getCreateCRMSoapHeader($CRMURL, $securityData). 
' 
     <s:Body> 
      <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"> 
      <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
       <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> 
        <b:KeyValuePairOfstringanyType>       
         <c:key>title</c:key> 
         <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">Its a sunday web case - second</c:value> 
        </b:KeyValuePairOfstringanyType>      
       </b:Attributes> 
       <b:EntityState i:nil="true"/> 
       <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/> 
       <b:Id>'.$accountId.'</b:Id> 
       <b:LogicalName>incident</b:LogicalName> 
       <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/> 
      </entity> 
      </Create> 
     </s:Body> 
    </s:Envelope> 
    '; 

$accountId looks like this: 
dabc10e9-df02-e611-80d9-5065f38a9b01 

は、私は次のエラーを取得していますか?

編集が更新され、これを試してみました:

' 
     <s:Body> 
      <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"> 
      <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
       <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> 
        <b:KeyValuePairOfstringanyType>       
         <c:key>title</c:key> 
         <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">Its a sunday web case - second</c:value> 
        </b:KeyValuePairOfstringanyType> 
        <b:KeyValuePairOfstringanyType> 
         <c:key>customerid</c:key> 
         <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">19622e39-e502-e611-80da-5065f38ada41</c:value> 
        </b:KeyValuePairOfstringanyType>                
       </b:Attributes> 
       <b:EntityState i:nil="true"/> 
       <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/> 
       <b:Id>00000000-0000-0000-0000-000000000000</b:Id> 
       <b:LogicalName>incident</b:LogicalName> 
       <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>      
      </entity> 
      </Create> 
     </s:Body> 
    </s:Envelope> 
    '; 

しかし、まだ同じエラー

編集#2、また試してみました:

' 
     <s:Body> 
      <Create xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"> 
      <entity xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
       <b:Attributes xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> 
        <b:KeyValuePairOfstringanyType>       
         <c:key>title</c:key> 
         <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">Its a sunday web case - second</c:value> 
        </b:KeyValuePairOfstringanyType> 
        <b:KeyValuePairOfstringanyType> 
         <c:key>customerid</c:key> 
         <b:value i:type="a:EntityReference"> 
          <a:Id>19622e39-e502-e611-80da-5065f38ada41</a:Id> 
          <a:LogicalName>account</a:LogicalName> 
          <a:Name i:nil="true" /> 
         </b:value> 
        </b:KeyValuePairOfstringanyType>                
       </b:Attributes> 
       <b:EntityState i:nil="true"/> 
       <b:FormattedValues xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/> 
       <b:Id>00000000-0000-0000-0000-000000000000</b:Id> 
       <b:LogicalName>incident</b:LogicalName> 
       <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>      
      </entity> 
      </Create> 
     </s:Body> 
    </s:Envelope> 
    '; 

とエラーになっています:

DeserializationFailedThe formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity . The InnerException message was 'Error in line 68 position 57. 'EndElement' 'KeyValuePairOfstringanyType' from namespace ' http://schemas.microsoft.com/xrm/2011/Contracts ' is not expected. Expecting element 'value'.'. Please see InnerException for more details.

答えて

1

Id属性にアカウントID値を設定しようとしている可能性があります。 Id属性は事件のIDを参照しています... CRMがあなたのためにIDを生成するようにするのが良いので、(新しい事件のIDを意図的に設定しようとしている場合を除いて)Id属性に何も指定しないでください。

エラーは、EntityReference型のcustomerid属性を参照しています。 EntityReferencesにはIdプロパティとLogicalNameプロパティがあります。 $accountIdの値をcustomerid.Idに入れ、customerid.LogicalNameを "account"にします。 EntityReferencesにはNameプロパティもありますが、それを指定する必要はありません。

編集#2は、名前空間の問題があるようです。試してみてください:

<b:KeyValuePairOfstringanyType> 
    <c:key>customerid</c:key> 
    <c:value i:type="b:EntityReference"> 
     <b:Id>19622e39-e502-e611-80da-5065f38ada41</b:Id> 
     <b:LogicalName>account</b:LogicalName> 
     <b:Name i:nil="true" /> 
    </c:value> 
</b:KeyValuePairOfstringanyType>  
+0

私のアップデートを見て、私は試しました。それでも同じエラーが発生します。 – mjhd

+0

@mjhdさんが私の答えを更新しました – Polshgiant