Error [bad request] Google Script to purge cache


I am currently trying to purge cache with google script but I got “bad request” as error.
I have no problem doing any other api call. It is just the call to purge cache that is giving me a bad request error and I just can’t find the reason for it.

Below is my script
function myFunction() {
var url = “[zone id i got from overview]/purge_cache”;
//var url = “”
//var url = “[zone id i got from overview]/settings/always_use_https”;
var data = {
var headers = {
‘method’ : ‘delete’,
“contentType”: “application/json”,
“X-Auth-Key”: “[global api key I get from my profile]”,
“X-Auth-Email”: “[my email for Cloudflare]”},
“payload”: JSON.stringify(data),
“muteHttpExceptions” : true

var response = UrlFetchApp.fetch(url, headers);


1 Like

Hi there - did you ever get this resolved? If not please file a ticket with support @ Cloudflare (if you haven’t already) and let me know the ticket number.