locked
REST endpoint update. RRS feed

  • Question

  • Hi I'm trying to update just the name of a contact in our Online CRM using the REST Endpoint with PHP.

    What I have for my request is:

                  <s:Body>
                        <Update 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>firstname</c:key>
                                    <c:value i:type="d:string" xmlns:d="http://www.w3.org/2001/XMLSchema">brad</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>af51b8f8-9695-e311-9e7c-6c3be5bd2bf8</b:Id>
                            <b:LogicalName>contact</b:LogicalName>
                            <b:RelatedEntities xmlns:c="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                        </entity>
                        </Update >
                    </s:Body>

    If anyone can tell me what i'm doing wrong or steer me in the right direction that would be great.

    Thank you.

    Friday, February 14, 2014 6:26 PM

All replies

  • You mentioned you are running this SOAP request from PHP - but if you do have Visual Studio you can download the CRM SDK and run the SOAPLogger application which generates the proper SOAP requests.

     <s:Body>
        <Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
          <request i:type="a:UpdateRequest" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
            <a:Parameters xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
              <a:KeyValuePairOfstringanyType>
                <b:key>Target</b:key>
                <b:value i:type="a:Entity">
                  <a:Attributes>
                    <a:KeyValuePairOfstringanyType>
                      <b:key>contactid</b:key>
                      <b:value i:type="c:guid" xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/">8eada9c2-f389-e311-b159-6c3be5bdd91c</b:value>
                    </a:KeyValuePairOfstringanyType>
                    <a:KeyValuePairOfstringanyType>
                      <b:key>firstname</b:key>
                      <b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">Brad</b:value>
                    </a:KeyValuePairOfstringanyType>
                  </a:Attributes>
                  <a:EntityState i:nil="true" />
                  <a:FormattedValues />
                  <a:Id>8eada9c2-f389-e311-b159-6c3be5bdd91c</a:Id>
                  <a:LogicalName>contact</a:LogicalName>
                  <a:RelatedEntities />
                </b:value>
              </a:KeyValuePairOfstringanyType>
            </a:Parameters>
            <a:RequestId i:nil="true" />
            <a:RequestName>Update</a:RequestName>
          </request>
        </Execute>
      </s:Body>



    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Friday, February 14, 2014 7:49 PM
    Moderator