I am using the following code to submit an HTTP delete request. I have this function for the Delete API call but it's not working. I cannot get the error message when trying it in a CloudPage, it gives me a blank page. Am I missing something?

function sendUsersToSegment(token, setup, payload, snapchatAudienceId) {
        var accessToken = token;
        var auth = 'Bearer ' + accessToken;
        var url = setup.snapRemoveUserURL + "/" +snapchatAudienceId+ "/users";
        var payload = payload;
        var req = new Script.Util.HttpRequest(url);
        req.emptyContentHandling = 0;
        req.retries = 2;
        req.continueOnError = true;
        req.contentType = "application/json"
        req.setHeader("Authorization", auth);
        req.method = "DELETE";
        req.postData = payload;

        var resp = req.send();
        if (resp.StatusCode == 201 || resp.StatusCode == 200) {
        var res = Platform.Function.ParseJSON(resp["Response"][0]);
        if (res.eventInstanceId != null && res.eventInstanceId != "") return true;
        } else {
            return false;
  • I have observed something similar using WSProxy delete, in my case it was deleting an automation. Extrapolating from that: I think delete works from automations, but not from cloudpages. This might be expected behavior. Another thing I recently saw that some other functionality (retrieveDataExtensionFields) only worked from published cloudpages. Worth a try, if it fails, I would go back to my first statement. – Jonas Lamberty Oct 21 at 8:27
  • What do you get when you Write(Stringify(resp));? – Macca Oct 21 at 10:21

Your Answer

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

Browse other questions tagged or ask your own question.