cloudflare-docs icon indicating copy to clipboard operation
cloudflare-docs copied to clipboard

export-graphql-to-csv doesn't work

Open codesse opened this issue 4 years ago • 3 comments

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

codesse avatar Jun 17 '21 11:06 codesse

Fixing the authentication issue in this tutorial leaves the query still not working with KeyError: 'viewer' error.

nnmalex avatar Oct 06 '21 11:10 nnmalex

Thanks for the report, I will have a look.

victor-perov avatar Aug 09 '22 19:08 victor-perov

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.

victor-perov avatar Aug 09 '22 19:08 victor-perov

I can't reproduce this issue. Please let us know if you are still seeing it.

victor-perov avatar Oct 06 '22 13:10 victor-perov