I have experience with cloudflare.com, park through their api domains, now there is such a problem, js and css files are cached on the side of cloudflare to clear the cache you need to go to the panel, select a domain and click a button, it’s all very simple if domain 1 or 5 pieces, but I have a little more of them and it takes a lot of time ... In general, I immediately went to look at the instructions for their api, their original description of what needs to be done to clear the cache:
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/purge_cache" \ -H "X-Auth-Email: user@example.com" \ -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \ -H "Content-Type: application/json" \ --data '{"purge_everything":true}' 023e105f4ecef8ad9ca31a8372d0c353 - this is the id of a specific domain, which I receive by the same api without problems
In Delphi, my code looks like this:
idhttp:=Tidhttp.Create(nil); SSL := TIdSSLIOHandlerSocketOpenSSL.Create(IdHTTP); SSL.SSLOptions.Method:= sslvTLSv1; SSL.SSLOptions.Mode:= sslmUnassigned; IdHTTP.IOHandler := SSL; idhttp.AllowCookies := true; idhttp.Request.CustomHeaders.Add('X-Auth-Email: My_email'); idhttp.Request.CustomHeaders.Add('X-Auth-Key: My_Auth_key'); idhttp.Request.ContentType:='application/json'; memory:=TStringStream.Create(); memory.WriteString('{"purge_everything":true}'); memory.Encoding.UTF8; try idhttp.Delete('https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/purge_cache',memory); except on E: EIdHTTPProtocolException do begin s:=E.ErrorMessage; end; end; Memo1.Lines.Add(s); In response, I get an error message like this:
{"success":false,"errors":[{"code":1012,"message":"Request must contain one of \"purge_everything\", \"files\", \"tags\", or \"hosts\""}],"messages":[],"result":null} It tells me "Request must contain one of" you must pass any one of the parameters listed below ...
So I transfer the data, just like in the previous tasks, only the sent data changes and the sending method was POST before, and here, according to the instructions, the DELETE method is required
Everything is done according to the instructions that he should not know ... Here is a link to the description page of the api to my task: https://api.cloudflare.com/#zone-purge-all-files
memory.Encoding.UTF8- this line de facto does nothing. Try creating a stream specifying the encoding:memory:=TStringStream.Create('', TEncoding.UTF8);- kamimemory.Encoding.UTF8linememory.Encoding.UTF8not matter, although previous requests did not work without it, removed it, wrote as you said, the error remained, the same one - libDELETEmethod - lib