Hi, I’m trying to ping the graphql API with python and javascript and running into some parsing problems. How would I convert the following to python using the requests package?
Copy code
query {
flow_run(where: {name: {_eq: "woodoo-leopard"}}) {
id
state
start_time
}
}
k
Kevin Kho
10/22/2021, 5:33 PM
I’ll give this a shot.
Kevin Kho
10/22/2021, 5:36 PM
You mean like this?
Copy code
import requests as re
query = """query {
flow_run(where: {name: {_eq: "..."}}) {
id
state
start_time
}
}"""
url = '<https://api.prefect.io>'
r = <http://re.post|re.post>(url, json={'query': query}, headers={"authorization": "Bearer API_KEY"})
print(r.status_code)
print(r.text)
h
Hugo Kitano
10/22/2021, 5:55 PM
awesome, thanks, this works. is there a reason why this is a post request? seems to me that this would be a get request, but it could be a graphql thing im not aware of
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.