403 permission denied on curl, but can access the report using a browser

Hey everyone!

I’m writing a CLI tool for my team using Clockify API. I’m at the point where I need to get the total work hours of the user using https://reports.api.clockify.me/v1/workspaces/WORKSPACE_ID/reports/summary, but I’m always getting this error {"code":403,"message":"You don't have a permission for that action"} although I could view the summary reports when using the browser. Do you know why it fails on my code (or simple curl command), but it’s working using a browser? Thanks!

Here’s the curl that I used to test it:

curl --request POST \
  --url https://reports.api.clockify.me/v1/workspaces/WORKSPACE_ID/reports/summary \
  --header 'content-type: application/json' \
  --header 'x-api-key: CLOCKIFY_API_KEY' \
  --data '{
    "dateRangeStart": "2024-04-01T00:00:00.000Z",
    "dateRangeEnd": "2024-04-30T23:59:59.000Z",
    "summaryFilter": {"groups": ["PROJECT", "USER", "TIMEENTRY"]},
    "exportType": "JSON",
    "users": {
    "ids": ["USER_ID"],
    "contains": "CONTAINS",
    "status": "ALL"
  }
}'
{"code":403,"message":"You don't have a permission for that action"}%  

Hello there,

Thanks for using the Forum!

Would you be able to reach out to the Support team at support@clockify.me for us to take a look at this as well?

Cheers,

Hi David, I just sent an email to support@clockify.me. Thank you.

This is now resolved. The support asked me to add this line to the body of the payload.

“amountShown”: “HIDE_AMOUNT”,

Curl now looks like…

curl --request POST \
  --url https://reports.api.clockify.me/v1/workspaces/WORKSPACE_ID/reports/summary \
  --header 'content-type: application/json' \
  --header 'x-api-key: CLOCKIFY_API_KEY' \
  --data '{
    "dateRangeStart": "2024-04-01T00:00:00.000Z",
    "dateRangeEnd": "2024-04-30T23:59:59.000Z",
    "summaryFilter": {"groups": ["PROJECT", "USER", "TIMEENTRY"]},
    "amountShown": "HIDE_AMOUNT",
    "exportType": "JSON",
    "users": {
    "ids": ["USER_ID"],
    "contains": "CONTAINS",
    "status": "ALL"
  }
}'
1 Like