I'm using geoserver with geowebcache and I need to use the REST API to truncate tiles in a bounding box so they can be rebuilt. All the examples in the documentation are in curl and I'm using JQuery. I'd like to do the call with $.ajax. Here's what I'm trying:
var formData = new FormData();
formData.append("threadCount", "01");
formData.append("type", "truncate");
formData.append("gridSetID", "EPSG:900913");
formData.append("format", "image/png");
formData.append("zoomStart", '00');
formData.append("zoomStop", '15');
formData.append("minX", "-12484306.954023438");
formData.append("minY", '3991847.3646093756');
formData.append("maxX", "-12445171.195546875");
formData.append("maxY", '4030983.1230859384');
var data = {
"threadCount": "01" ,
"type": "truncate",
"gridSetID": "EPSG:900913",
"format": "image/png",
"zoomStart": '00',
"zoomStop": '15',
"minX": "-12484306.954023438",
"minY": '3991847.3646093756',
"maxX": "-12445171.195546875",
"maxY": '4030983.1230859384'
};
var ajaxResponse = $.ajax({
type: "get",
url: "http://localhost/geoserver/gwc/rest/seed/MyWorkspace:cityJoin",
contentType: false,
data: data,
processData: true,
cache: false
});
I have tried several variations of this code. I've tried sending the formData and the data, get and post, and I've changed the contentType variable between false, multipart-form, and json. I've also had processData set to true and false and not included at all. I've also tried appending all the data to the url and sending it that way. The data I'm using comes from a call the Geowebcache seeding page makes. I get one of three results based on the settings I use: 1. the call goes through but no tiles get truncated. 2. Illegal Invocation error. 3. Internal server error. I can't get it to run the truncate. Does anyone have an example of how to run the truncate with $.ajax or have an idea why my code isn't working?