1

I am trying to make a SOAP call to create new accounts and update campaign members in our sandbox salesforce crm from Marketing cloud landing page under webstudio

When I publish it, I am getting below error:

{"StatusCode":500,"Response":"{\"message\":\"An error occurred when attempting to evaluate a HTTPPost function call. See inner exception for details.\",\"description\":\"ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to evaluate a HTTPPost function call. See inner exception for details.\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nSystem.Net.WebException: The remote server returned an error: (500) Internal Server Error. - from System\r\n\r\n\r\n\r\n\"}"}

Please suggest. Thanks!

Api call:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script language='javascript' runat=server>
    Platform.Load("core","1");
    var username = 'xxxxxxxxxxxx';
var password = 'xxxxxxxxx';
var payload = '';
var endpoint = "https://tmca--uat.cs96.my.salesforce.com/services/Soap/u/45.0";
var result;

payload += '<?xml version="1.0" encoding="UTF-8"?>';
payload += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com">';
payload += '   <soapenv:Header>';
payload += '         <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">';
payload += '            <UsernameToken>';
payload += '            <Username>username</Username>';
payload += '            <Password>password</Password>';
payload += '          </UsernameToken>';
payload += '      </Security>';
payload += '   </soapenv:Header>';
payload += '   <soapenv:Body>';
payload += '        <gues:guestWebservices>';
payload += '            <gues:request>';                     
payload += '                <gues:campaignDetailsWrapper>';
payload += '                <gues:campaignDetailList>';
payload += '                <gues:campaignCode>MOTO_86_2019PHIL</gues:campaignCode>';
payload += '                <gues:campaignName>Phillip Island 2019</gues:campaignName>';
payload += '                </gues:campaignDetailList>';
payload += '                </gues:campaignDetailsWrapper>';
payload += '                <gues:guestDetails>';
payload += '            <gues:email>rcoctober22@gmail.com</gues:email>';
payload += '            <gues:firstName>Rohit</gues:firstName>';
payload += '            <gues:lastName>Chauhan</gues:lastName>';
payload += '            <gues:phone>8700xxxxxx</gues:phone>';
payload += '            <gues:personmobilephone>8700668828</gues:personmobilephone>';
payload += '            </gues:guestDetails>';
payload += '            <gues:webFormType>Sponsorships_Events</gues:webFormType>';
payload += '            </gues:request>';
payload += '        </gues:guestWebservices>';
payload += '   </soapenv:Body>';
payload += '</soapenv:Envelope>';

  try {
    result = HTTP.Post(endpoint, "text/xml", payload, ["SOAPAction"], ["Create"]);
} catch(e) {
    result = {StatusCode:500,Response:Stringify(e)};    
}

if (result.StatusCode != 200) {
    //Bad response
    Write(Stringify(result));
} else {
    //Good response
    Write(Stringify(result));
}

    </script> 
</body>
</html> 
  • Have you confirmed that the SOAP call works outside of the page -- like with SOAP UI or Postman? – Adam Spriggs Jan 29 at 14:20
  • Yes, Adam. I tried the soap envelope in SOAP UI and it worked fine and send data in sfdc. – Rohit Chauhan Jan 29 at 19:22
  • You're not using the username and password variables in your payload... – Adam Spriggs Jan 30 at 15:10
0

The Salesforce CRM Partner API doesn't support the same UsernameToken authentication that Marketing Cloud does.

You can't just put the username and password details in a SOAP header for the Partner API. Instead you need to use the login call to get a session ID and Server URL. Those details can then be used via the SOAP SessionHeader to make subsequent calls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.