1

I'm trying to delete contacts based on DE. So far I'm testing the code on cloud page but eventually, it will be used as part of automation. I'm successfully retrieving a token but struggle to execute the call to delete contacts and receive an error: Unable to retrieve security descriptor for this frame.

The similar call seems to work fine when tested in Postman.

 <script runat=server>
Platform.Load("Core", "1");

// Authorization 

var url = '<auth endpoint>; 
var contentType = 'application/json'; 
var payload = '{"client_id": "<clientid>","client_secret": "<clientsecret>", "grant_type": "client_credentials"}'; // Specifying the access credentials

var accessTokenResult = HTTP.Post(url, contentType, payload); 
var accessToken = Platform.Function.ParseJSON(accessTokenResult["Response"][0]).access_token;

  if (accessToken !='') {
  Platform.Response.Write(accessToken);
  }
  else
  {
  Platform.Response.Write('Auth failed');
  }


  var payLoadDeletion = {
 "deleteOperationType": "ContactAndAttributes",
 "targetList": {
   "listType": {
     "listTypeID": 3
   },
   "listKey": "2A052B10-24B7-42A4-81A2-B91E0E1E48B4"
 },
 "deleteListWhenCompleted": false,
 "deleteListContentsWhenCompleted": false
}


  try {

 var urlDelete = '<API endpoint>/contacts/v1/contacts/actions/delete?type=listReference';
 var contentTypeDelete = 'application/json';
  var headerNames = ["Authorization"]; 
  var s1="Bearer ";
  var headerValues = s1.concat(accessToken); 
   var reply;
   var result = HTTP.Post(urlDelete, contentTypeDelete, payLoadDeletion, headerNames, headerValues); 

     } catch (err) {
         Platform.Response.Write("<br><br>Error: " + err);
     }

1 Answer 1

5

There are two adaptions you need to make to get your example to work:

  • Supply the payload as string using Stringify(payLoadDeletion)
  • Supply the headerValues as Array: var headerValues = ["Bearer " + accessToken];
2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .