Purge File using golang

api, err := Cloudflare.New(“99999999999a7bcc1b79e523a8e84ec999999”, “[email protected]”)

if err != nil {
	fmt.Fprintf(w, "CLoudflare New Err %s\n", err)
}

ctx := context.Background()

f := []string{"https://test.example.com/alpha"}

pcr := cloudflare.PurgeCacheRequest{Files: f}

_, err = api.PurgeCache(ctx, "example.com", pcr)
if err != nil {
	fmt.Fprintf(w, "Purge Cache err %s\n", err)
}

RESULT
Purge Cache err Could not route to /client/v4/zones/example.com/purge_cache, perhaps your object identifier is invalid? (7003)

I figured it out.*

in the purge cache command, I used to domain - example com instead of the zone id which is a hex # on the lower right side of overview.

I discovered an Cloudflare error bug in the Cloudflare new command. It will authenticate without an error regardless of what nonsense you put in. The authentication error appears when you run the purgecache or any I am guessing any other API command.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.