Greetings Everyone,
I'm attempting to use
prefect.Client
to query the GraphQL endpoint, however, I am
getting errors that have me stumped. The relevant code:
import prefect
import pandas as pd
client = prefect.Client()
client.graphql("""
query {
agent{
flow_runs(limit:5, where:{state:{_eq: "Success"}start_time:{_gt:"2022-02-14"}}){
start_time
end_time
state
flow{
name
id
tasks_aggregate{
aggregate{
count
}
}
}
}
}
} """)
The errors:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 465, in _request
json_resp = response.json()
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/workspaces/prefect/ETL/CDNY/GraphQL.py", line 7, in <module>
client.graphql("""
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 298, in graphql
result = <http://self.post|self.post>(
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 213, in post
response = self._request(
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 468, in _request
raise ClientError(
prefect.utilities.exceptions.ClientError: Malformed response received from Cloud - please ensure that you have an API token properly configured.
We're using Prefect core as our backend at the moment and the documentation for this is sparse when I google. Thanks