Detail report API to GCP

Hi,
I’m trying to use the clockify API to pull a detailed report into GCP. For this I’m using a function to generate a csv, and get the following message 403 - {“code”:403, “message”: “You don´t have permission for that action”}
The function looks like this:

import requests
from datetime import datetime
from google.cloud import storage
import pandas as pd
from io import BytesIO

def clockify_to_gcs(request):
# Configuración de la API de Clockify
api_key = “XXXXXX”
workspace_id = “XXXXX”
clockify_url = f’https://reports.api.clockify.me/v1/workspaces/{workspace_id}/reports/detailed

bucket_name = 'ingesta_bucket' 
client = storage.Client()
bucket = client.get_bucket(bucket_name)


start_date = datetime(2024, 1, 1).strftime('%Y-%m-%dT%H:%M:%SZ')  
end_date = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ') 
detailed_filter = {
    'startDate': start_date,
    'endDate': end_date,
}
params = {
    'dateRangeStart': start_date,
    'dateRangeEnd': end_date,
    'detailedFilter': detailed_filter,
}


headers = {
    'X-Api-Key': api_key,
    'Content-Type': 'application/json',
}


response = requests.post(clockify_url, headers=headers, json=params)


if response.status_code == 200:
    data = response.json()
    df = pd.DataFrame(data)


    csv_data = BytesIO()
    df.to_csv(csv_data, index=False)
    blob = bucket.blob(f'Reporte_Clockify_Completo.csv')
    blob.upload_from_file(csv_data, content_type='text/csv')
    
    return 'Datos de Clockify cargados exitosamente en GCS.'

return f'Error en la solicitud a Clockify: {response.status_code} - {response.text}'

Any advice on what I’m doing wrong would be greatly appreciated.

Thanks

Hello Franco,

Could you please let me know your current role within the workspace?
This is most likely an issue with the permissions in your workspace in case you have a Regular user role where regular users do not have permission to see all the details about the time entry and this can’t be modified within the API.

An example would be if billability status or amounts are hidden from the regular users, you won’t be able to generate a report as our detailed report via API gives this information as well. Due to this reason, API requests will give you a forbidden error since you can’t see some of the information that our API provides.

Could you please contact us at support@clockify.me so one of our agents can check it out for you if this is not the case?