Error [bad request] Google Script to purge cache


#1

Hi,

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 = “https://api.cloudflare.com/client/v4/zones/[zone id i got from overview]/purge_cache”;
//var url = “https://api.cloudflare.com/client/v4/zones?name=edkl.media&status=active&page=1&per_page=20&order=status&direction=desc&match=all”
//var url = “https://api.cloudflare.com/client/v4/zones/[zone id i got from overview]/settings/always_use_https”;
var data = {
“purge_everything”:false
//“value”:“off”
};
var headers = {
‘method’ : ‘delete’,
“contentType”: “application/json”,
“headers”:{
“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);

Logger.log(JSON.parse(response.getContentText()));
}


#2

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.