I am trying to retrieve sender profile by doing soap call via ssjs:


var payload = '';
var endpoint = "https://mcrd367cfywzf2wz7gc7ln-dc7fq.soap.marketingcloudapis.com/Service.asmx";
var result;

payload += '<?xml version="1.0" encoding="UTF-8"?>;
payload += '<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">;
payload += '<s:Header>;
payload += '<a:Action s:mustUnderstand="1">Retrieve</a:Action>;
payload += '<a:To s:mustUnderstand="1">https://XXXX.soap.marketingcloudapis.com/Service.asmx</a:To>;
payload += '<fueloauth xmlns="http://exacttarget.com">XXXXXXX</fueloauth>;
payload += '</s:Header>;
payload += '<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">;
payload += '<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">;
payload += '<Options>;
payload += '</Options>;
payload += '<RetrieveRequest>;
payload += '<ObjectType>SenderProfile</ObjectType>;

payload += '<Properties>ObjectID</Properties>;

payload += '<Properties>CustomerKey</Properties>;
payload += '<Properties>FromName</Properties>;
payload += '<Properties>FromAddress</Properties>;

payload += '<Properties>Description</Properties>;
payload += '<Properties>SenderHeaderEmailAddress</Properties>;
payload += '<Properties>SenderHeaderName</Properties>;
payload += '<QueryAllAccounts>true</QueryAllAccounts>;
payload += '</RetrieveRequest>;
payload += ' </RetrieveRequestMsg>;
payload += ' </s:Body>;
payload += '</s:Envelope>;

try {
    result = HTTP.Post(endpoint,"text/xml",payload,["SOAPAction"],["Retrieve"]);

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

But I am finding 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. after publishing and clicking on the cloudpage link.

Can anybody point out what is the problem in the code?

1 Answer 1


When using SSJS, it is much easier to interact with SOAP API objects using WSProxy. The example you've listed above could be written as the following:

<script runat = "server" >
Platform.Load("core", "1.1.5");
try {
    var prox = new Script.Util.WSProxy();
    var queryAllAccounts = true;
    var cols = ["CustomerKey", "FromName", "FromAddress", "Description", "SenderHeaderEmailAddress", "SenderHeaderName"];
    var data = prox.retrieve("SenderProfile", cols, queryAllAccounts)
    Write("Result: " + Stringify(data));
} catch (e) {
  • Hi, I have used the above code in cloudpage but I am having the following error :{"message":"Unable to retrieve security descriptor for this frame.","description":"System.InvalidOperationException: Unable to retrieve security descriptor for this frame. - from mscorlib\r\n\r\n"}
    – user96720
    May 4, 2021 at 12:03
  • Are you including anything else on the cloudpage other than the above script? I've tested this and it executes as intended on my end. May 4, 2021 at 13:55
  • No I am just using this code only but I am getting the above error
    – user96720
    May 5, 2021 at 9:35
  • getting this while publishing :``{"message":"Exception has been thrown by the target of an invocation.","description":"System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. - from mscorlib --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.FunctionExecutionException: WSProxy object is not valid in sendable content. This function is only allowed in non-sendable content.\r\n Object: Script.Util.WSProxy()\r\n Error Code: OMM_FUNC_CONTEXT_ERR\r\n - from OMMCommon\r\n\r\n\r\n\r\n"}
    – user96720
    May 5, 2021 at 9:55
  • Are you seeing that error in the preview mode and not on the live/published page? There is an issue with the preview functionality such that, when running WS Proxy scripts like the above, it will always show that error in preview but the live site will execute the code correctly. May 5, 2021 at 12:55

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.