To execute the SOAP call in SSJS with the provided envelope, you need to make sure that the subdomain and access_token are properly replaced with your actual Marketing Cloud subdomain and OAuth access token, respectively. Here's a complete SSJS script to perform this SOAP call:
<script runat="server">
Platform.Load("Core", "1.1.1");
// Define the necessary parameters
var subdomain = 'YOUR_SUBDOMAIN'; // Replace with your subdomain
var accessToken = 'YOUR_ACCESS_TOKEN'; // Replace with your OAuth access token
// Construct the SOAP request
var soapMessage =
'<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">' +
' <s:Header>' +
' <a:Action s:mustUnderstand="1">Update</a:Action>' +
' <a:To s:mustUnderstand="1">https://' + subdomain + '.soap.marketingcloudapis.com/Service.asmx</a:To>' +
' <fueloauth xmlns="http://exacttarget.com">' + accessToken + '</fueloauth>' +
' </s:Header>' +
' <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
' <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">' +
' <Objects xsi:type="DataExtension">' +
' <CustomerKey>FormSubmission</CustomerKey>' +
' <Fields>' +
' <Field>' +
' <ObjectID>2de69d87-fefb-4fc5-819e-7f03fe51512a</ObjectID>' +
' <Name>EmailAddress</Name>' +
' </Field>' +
' </Fields>' +
' </Objects>' +
' </UpdateRequest>' +
' </s:Body>' +
'</s:Envelope>';
// Define the endpoint URL
var endpoint = 'https://' + subdomain + '.soap.marketingcloudapis.com/Service.asmx';
// Send the SOAP request
var result = HTTP.Post(endpoint, 'text/xml', soapMessage, ["SOAPAction"], ["Update"]);
var statusCode = result.StatusCode;
var response = result.Response;
// Output the result
Write('<br>Status Code: ' + statusCode);
Write('<br>Response: ' + Stringify(response));
</script>
Replace Placeholders:
YOUR_SUBDOMAIN: Replace with your actual Marketing Cloud subdomain.
YOUR_ACCESS_TOKEN: Replace with your valid OAuth access token.
Test the Script:
Add this SSJS code to a CloudPage or Script Activity in Marketing Cloud.
Ensure you have the necessary permissions and that the endpoint and token are correctly set up.
Review the Response:
The script will output the HTTP status code and response from the server. Check these outputs to understand the success or failure of the SOAP call.
Ensure that your access token is valid and has the necessary permissions to perform the update request on the Data Extension. If there are issues, the response and status code should give you clues on what might be wrong.