locked
Error trying to Create a new record using SOAP RRS feed

  • Question

  • Hi,

    I have a custom entity called xyz_trainingmatch with a N:1 relationship to xyz_trainingapplication and another N:1 relationship to xyz_trainingopportunity.

    I'm trying to create a new xyz_trainingmatch record using SOAP with the following code:

    var xml = "" +
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
    GenerateAuthenticationHeader() +
    " <soap:Body>" +
    " <Create xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
    " <entity xsi:type='xyz_trainingmatch'>" +
    " <xyz_trainingopportunityid>{900C9990-ED50-DE11-A6CD-000C29526602}</xyz_trainingopportunityid>" +
    " <xyz_trainingapplicationid>{507D4558-CE51-DE11-8712-000C297C5F75}</xyz_trainingapplicationid>" +
    " <xyz_opportunitystatus>1</xyz_opportunitystatus>" +
    " </entity>" +
    " </Create>" +
    " </soap:Body>" +
    "</soap:Envelope>" +
    "";
    The above code gives me the following error in the response XML:

    <?xml version="1.0"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Server was unable to process request.</faultstring><detail><error>
    					<code>0x80040203</code>
    					<description>query</description>
    					<type>Platform</type>
    				</error></detail></soap:Fault></soap:Body></soap:Envelope>
    Is there any special way to create new records with N:1 relationships that I need to specify in my soap message string?

    Your help is highly appreciated.

    Thanks.

    R
    Tuesday, June 9, 2009 8:38 AM

Answers

  • Hi.

    There are error in your code in line

     xmlHttpRequest.setRequestHeader("SOAPAction"
    ," http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple"
    );
    must be

     xmlHttpRequest.setRequestHeader("SOAPAction"
    ," http://schemas.microsoft.com/crm/2007/WebServices/Create"
    );

    I hope this will help you.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    • Marked as answer by BlueSting Tuesday, June 9, 2009 10:01 AM
    Tuesday, June 9, 2009 9:53 AM
    Moderator

All replies

  • Hi. Could you give your full script's code for investigation because your request xml seems to be wright.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    Tuesday, June 9, 2009 8:55 AM
    Moderator
  • Hi Andriy,

    Thanks for the reply.

    Below is the other half of the code:

    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
         
         xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
         xmlHttpRequest.setRequestHeader("SOAPAction"," http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
         xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
         xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
         xmlHttpRequest.send(xml);
    
        var resultXml = xmlHttpRequest.responseXML;
    Tuesday, June 9, 2009 9:41 AM
  • Hi.

    There are error in your code in line

     xmlHttpRequest.setRequestHeader("SOAPAction"
    ," http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple"
    );
    must be

     xmlHttpRequest.setRequestHeader("SOAPAction"
    ," http://schemas.microsoft.com/crm/2007/WebServices/Create"
    );

    I hope this will help you.
    Truth is opened the prepared mind My blog - http://a33ik.blogspot.com
    • Marked as answer by BlueSting Tuesday, June 9, 2009 10:01 AM
    Tuesday, June 9, 2009 9:53 AM
    Moderator
  • Andriy,

    Thank you very much for pointing that out.

    That indeed did solve my issue.

    Thanks again.

    R
    Tuesday, June 9, 2009 10:01 AM