cloudflare-docs
cloudflare-docs copied to clipboard
export-graphql-to-csv doesn't work
Expected Behavior
https://github.com/cloudflare/cloudflare-docs/blob/production/products/analytics/src/content/graphql-api/tutorials/export-graphql-to-csv/index.md
Actual Behavior
After inserting the values in the 'complete script' : api_email = '[your email here]' api_token = '[your API token here]' api_account = '[your account ID here]'
I try the execute the program and get :
ValueError: Invalid header name b'Authorization: Bearer'
It seems that ':' isn't liked by the 'requests' module. If I delete the ':' then I get :
{"success":false,"errors":[{"code":9106,"message":"Missing X-Auth-Key, X-Auth-Email or Authorization headers"}]}
Section that requires update
https://github.com/cloudflare/cloudflare-docs/blob/production/products/analytics/src/content/graphql-api/tutorials/export-graphql-to-csv/index.md
Additional information
No more info needed
Fixing the authentication issue in this tutorial leaves the query still not working with KeyError: 'viewer' error.
Thanks for the report, I will have a look.
I copied the script from The final script part of the related tutorial as gql2csv.py (see below), replaced creds, and was able to successfully execute it (Darwin, was also able to run it on Debian):
viktor@machine cloudflare-docs % python3 gql2csv.py
Successfully exported to network-analytics-2022-08-01-2022-08-08.csv
However, I can imagine the script does not catch all errors therefore KeyError: 'viewer' might appear. I will check that case later.
I can't reproduce this issue. Please let us know if you are still seeing it.