Logs – Unable to Enable Retention

I’m trying to retrieve logs from the API and I see before I can pull logs, I need to enable log retention.

curl -s -H "X-Auth-Email: " -H "X-Auth-Key: " GET “https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/logs/control/retention/flag” | jq .

Gives me the response I’m expecting (checking if the log retention is on or not)

But then when I turn on the log retention, I get an error that is no where to be found in the Cloudflare support community.

curl -s -H "X-Auth-Email: " -H "X-Auth-Key: " POST “https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/logs/control/retention/flag” -d’{“flag”:true}’ | jq .

{“errors”:[{“code”:400,“message”:“error parsing payload invalid character ‘\’’ looking for beginning of value”}],“messages”:,“result”:null,“success”:false}

Seems like that’s an error on their end. I even tried printing it to a log using ‘> output.logs’ and parsed by jq, with the same error.

Thanks!

Just to confirm, you’re an enterprise customer, right? Logpull is available to customers on the Enterprise plan.

2 Likes

Correct, I am enterprise.

I just did this API call this afternoon:

curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/logs/control/retention/flag" \
     -H "X-Auth-Email: EMAIL" \
     -H "X-Auth-Key: KEY" \
     -H "Content-Type: application/json" \
     --data '{"flag":true}'

Your curl flags are different from mine.

1 Like

I appreciate your response… but I still get the same error.

cmd> curl -s -H “X-Auth-Email: EMAIL” -H “X-Auth-Key: KEY” POST “https://api.cloudflare.com/client/v4/zones/ZONE_ID/logs/control/retention/flag” -d’{“flag”:true}’
{“errors”:[{“code”:400,“message”:“error parsing payload invalid character ‘\’’ looking for beginning of value”}],“messages”:,“result”:null,“success”:false}

I figured it out! I’m on Windows 10 and using the cmd line, so there was a few changes I needed to make to the curl command, adding a backslash () in front of the quotes and using double quotes around the flag data object.

This worked for me:
curl -s -H “X-Auth-Email: " -H “X-Auth-Key: " POST “https://api.cloudflare.com/client/v4/zones//logs/control/retention/flag” -d”{\“flag\”:true}”

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