Hello I am trying to pull activity log data from my board but am getting a 500 internal server error. The monday.com status site says everything is up and running though. Is there anything wrong with my request?
Hi @Jmiller1!
GraphQL APIs use a single endpoint for all operations (unlike REST APIs). Our API endpoint is:
https://api.monday.com/v2
You’ll need to write a query for Activity Logs, for example:
query {
boards (ids: 1234567890) {
activity_logs (from: "2021-07-23T00:00:00Z", to: "2021-07-26T00:00:00Z") {
id
event
data
}
}
}
Additionally, requests to the API should follow these rules:
- POST request with a JSON-formatted body
- Access token must be sent in the Authorization header. Learn more here: Authentication
- All queries (including mutations) should be sent with the
query
key in your JSON body - Optional variables should use the
variables
key - Content Type header must be
application/json
, unless you’re uploading Files
I hope this helps!
Hi Alessandra, thank you for the response. I was able to find the link you sent above, but I can’t figure out how it plugs into the python query. I attached a picture of how the documentation says to format in Python, how does what you provided plug into that structure?
Hello there @Jmiller1,
I have created an example for you on Postman and exported it to:
Python - http.client:
import http.client
import json
conn = http.client.HTTPSConnection(“api.monday.com”)
payload = “{“query”:“query {\n boards (ids: 1234567890) {\n activity_logs (from: "2023-05-10T00:00:00Z", to: "2023-05-22T00:00:00Z") {\n id\n event\n data\n }\n }\n}”,“variables”:{}}”
headers = {
‘Authorization’: ‘APIKEYHERE’,
‘Content-Type’: ‘application/json’,
}
conn.request(“POST”, “/v2”, payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode(“utf-8”))
–
Python - Requests:
import requests
import json
url = “https://api.monday.com/v2”
payload=“{“query”:“query {\n boards (ids: 1234567890) {\n activity_logs (from: "2023-05-10T00:00:00Z", to: "2023-05-22T00:00:00Z") {\n id\n event\n data\n }\n }\n}”,“variables”:{}}”
headers = {
‘Authorization’: ‘APIKEYHERE’,
‘Content-Type’: ‘application/json’,
}
response = requests.request(“POST”, url, headers=headers, data=payload)
print(response.text)
I hope that helps!
Cheers,
Matias