Hi, I’m trying to ping the graphql API with python...
# ask-community
h
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
I’ll give this a shot.
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
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
k
I think all GraphQL queries are post requests
👍 1