В моем проекте всякий раз, когда вызывается API, он кэшируется в Akamai. Но когда клиент что-то меняет в базе через UI. Нам нужно аннулировать кешированный ответ API в AKAMAI и заполнить его новыми свежими данными json. Я нашел ссылку в Интернете: akamai-purging, но я не могу понять, что такое cp-код в этой ссылке они говорят?
Вот мой пример кода, который выдает: 405 Not Allowed
Код:
public static void main(String[] args) throws IOException, RequestSigningException {
URL url = new URL("https://xxx-host-name-/scripts.4535eaf743502b25ba3a.js");
HttpTransport HTTP_TRANSPORT = new ApacheHttpTransport();
HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory();
AkamaiPostData postData = new AkamaiPostData();
postData.setHostname(AkamaiConstants.SITE_HOST_NAME);
Gson gson = new Gson();
String postDataJSON = gson.toJson(postData);
byte[] contentBytes = postDataJSON.getBytes();
HttpContent content = new ByteArrayContent("application/json", contentBytes);
HttpRequest request = requestFactory.buildDeleteRequest(new GenericUrl(url));
HttpHeaders headers = request.getHeaders();
headers.set("Host", "xxx-host-name-");
ClientCredential credential = new DefaultCredential(AkamaiConstants.CLIENT_TOKEN, AkamaiConstants.ACCESS_TOKEN, AkamaiConstants.CLIENT_SECRET);
RequestSigner signer = new EdgeGridV1Signer(Collections.EMPTY_LIST, 1024 * 2);
HttpRequest signedRequest = signer.sign(request, credential);
HttpResponse response = signedRequest.execute();
String result = response.parseAsString();
System.out.println("result::" + result);
}