I can successfully place a very simple query in the interactive client, as well as using cURL:
query{account{id, name}}
But when I place the same query using Python, I get the following response:
'{"errors":[{"message":"No query string was present"}],"account_id":XXXXXXX}'
The API authentication works, because I am getting my account id back with the response. But every method I use returns “No query string was present”. Any ideas?
My relevant code snippet:
headers = {"Authorization" : creds.api_token}
request = requests.post(creds.monday_api_url,
json={"query" : "{account{id, name}}"},
headers=headers)
if request.status_code == 200:
return request.json()
else:
raise Exception(
"""
Query failed to run by returning code of {}. {}
""".format(request.status_code, query))
I did try without the outer braces and that didn’t work. You do need to include the outer braces.
However, I think there’s something else going on here – a “no query string was present” error means the server thinks the body of your request is empty. If there was a syntax error, you’d receive a ParseError like this:
Well, I’ve got things working now - embarrassingly, the URL I was using was: http://api.monday.com/v2, when it should have been https://api.monday.com/v2