0

I am using the below code to delete contacts. I am getting a HTTP post error. Not able to find any obvious error. Would appreciate any insight from the community.

This is the error message I am getting:

"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: (596). - from System\r\n\r\n\r\n\r\n"}

This is my code:

var url = "https://mysfmc-6384.rest.marketingcloudapis.com";
          url += "/v1/contacts/actions/delete?type=listReference";
          var DE_KEY="my_de_key";
          var headerNames = ["Authorization"];
          var headerValues = ["Bearer " + accessToken];
          var contentType = "application/json";
          var payload = '{';
          payload += ' "deleteOperationType": "ContactAndAttributes",';
          payload += ' "targetList": {';
          payload += '   "listType": {';
          payload += '     "listTypeID": 3';
          payload += '   },';
          payload += '   "listKey": "' + DE_KEY  + '"';
          payload += ' },';
          payload += ' "deleteListWhenCompleted": false,';
          payload += ' "deleteListContentsWhenCompleted": true';
          payload += '}';
          Platform.Response.Write(payload);
         result = HTTP.Post(url, contentType, payload, headerNames, headerValues);
          result = Stringify(result).replace(/[\n\r]/g, '');
          Platform.Response.Write(result);
          Platform.Response.Write("Test");

1 Answer 1

2

Looks like you do not have the correct url.

Try:

/contacts/v1/contacts/actions/delete?type=listReference

Instead of:

/v1/contacts/actions/delete?type=listReference
8
  • Thanks but it gives a 400 error. Also, I checked the REST end point in Postman and it works. Commented Jun 20, 2019 at 21:49
  • 400 error is better than 596. 596 signifies a bad url, which you had. 400 is probably on account of an issue in your payload. What does the payload you are sending in Postman look like?
    – Mike
    Commented Jun 20, 2019 at 21:50
  • And what does the payload you are sending in that code snippet look like as a full, serialized string? I am unsure what language you are using there.
    – Mike
    Commented Jun 20, 2019 at 21:51
  • Thanks, this is Server Side Java Script. Also 400 is page not found. How you are determining 596 means bad url? Curious as I tried to look that error up, couldn't find anything conclusive. Commented Jun 21, 2019 at 3:15
  • Can you do a Platform.Function.ParseJSON(payload) just to check the JSON is well formed? I always create the payload as a JSON and then in the post method perform a Stringify(payload)
    – SebOB
    Commented Jun 21, 2019 at 12:12

You must log in to answer this question.

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