Hello there @Milbourn and welcome to the community!
I hope you like it here 💪
The activity logs will not show individual logs.
I believe the closest you can get to that would be to check all the events for a specific items, check the “running” field to see when it was set to “running” and when it was paused, and with a script, build the individual logs.
Cheers,
Matias
Hello! Thanks for the welcome and for responding!
Just in the meantime I’ve found this code:
{
items(ids: 5256361xxx) {
column_values {
id
value
... on TimeTrackingValue {
history {
status
ended_at
started_at
started_user_id
manually_entered_end_date
}
}
}
id
}
}
Which appears to give me what i am after on the playground (historical time logs)
but when i run it through python
import requests
import json
# Your Monday.com API key
api_key = 'xxx'
# The GraphQL query
query = '''
{
items(ids: 5256361524) {
column_values {
id
value
... on TimeTrackingValue {
history {
status
ended_at
started_at
started_user_id
manually_entered_end_date
}
}
}
id
}
}
'''
# The API endpoint
url = 'https://api.monday.com/v2'
# Headers for the request
headers = {
'Authorization': api_key,
'Content-Type': 'application/json'
}
# Send the request
response = requests.post(url, headers=headers, json={'query': query})
# Print the response
print(response.json())
I recieve the following error and I am struggling to find a work around. Do you or anyone else have any advice?
{'errors': :{'message': "Field 'on' doesn't exist on type 'ColumnValue'", 'locations': :{'line': 7, 'column': 7}], 'path': :'query', 'items', 'column_values', 'on'], 'extensions': {'code': 'undefinedField', 'typeName': 'ColumnValue', 'fieldName': 'on'}},
{'message': "Field 'TimeTrackingValue' doesn't exist on type 'ColumnValue'", 'locations': :{'line': 7, 'column': 10}], 'path': :'query', 'items', 'column_values', 'TimeTrackingValue'], 'extensions': {'code': 'undefinedField', 'typeName': 'ColumnValue', 'fieldName': 'TimeTrackingValue'}}], 'account_id': 10523xxx}
Hello again,
I do not have experience with Python, but it looks like the 3 dots might not be being taken as it should. I recreated this query in Postman and exported it to Python. I hope that helps!
Python - Requests:
import requests
import json
url = "https://api.monday.com/v2/"
payload = "{\\"query\\":\\"{\\\\n items(ids: 5256361524) {\\\\n column_values {\\\\n id\\\\n value\\\\n ... on TimeTrackingValue {\\\\n history {\\\\n status\\\\n ended_at\\\\n started_at\\\\n started_user_id\\\\n manually_entered_end_date\\\\n }\\\\n }\\\\n }\\\\n id\\\\n }\\\\n}\\",\\"variables\\":{}}"
headers = {
'API-Version': '2023-10',
'Authorization': 'MYAPITOKEN',
'Content-Type': 'application/json',
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Python http.client:
import http.client
import json
conn = http.client.HTTPSConnection("api.monday.com")
payload = "{\\"query\\":\\"{\\\\n items(ids: 5256361524) {\\\\n column_values {\\\\n id\\\\n value\\\\n ... on TimeTrackingValue {\\\\n history {\\\\n status\\\\n ended_at\\\\n started_at\\\\n started_user_id\\\\n manually_entered_end_date\\\\n }\\\\n }\\\\n }\\\\n id\\\\n }\\\\n}\\",\\"variables\\":{}}"
headers = {
'API-Version': '2023-10',
'Authorization': 'MYAPITOKEN',
'Content-Type': 'application/json',
}
conn.request("POST", "/v2/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Cheers,
Matias
@Matias.Monday included it in his example but doesn’t seem to call it out directly, but you also need to set API-Version header to 2023-10 for the column value fragments for various column types to work.
Thank you @anon29275264!
I totally missed that it was missing on the script that was posted, and is probably why this was not working!
Cheers,
Matias
Thank you @Matias.Monday so so so so much! Can now run the time logs without issue!!
I had not being setting the API-Version header to 2023-10 in my other queries and had some success, but thank you @anon29275264 for letting me know. Will include that going forward.
Thank you both 😁 😁 😁 😁 😁
Happy to help @Milbourn !