clockify

getting all clockify users with all memberships


I inherited someone elses GO code that stopeed working. After brief debugging it seems the culprit is one of last API changes in clockify:

Updated default parameter for "Find all users on workspace" from ALL to NONE

This is how I try to get data with curl:

curl \
--request GET \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-API-KEY:myAPIkey" \
-d '{"memberships":"ALL"}' \
--url "https://api.clockify.me/api/v1/workspaces/myworkspaceID/users"  > ./out.txt

and here is example (edited) output:

[
    {
        "id": "111111111111111",
        "email": "xxx@google.com",
        "name": "Real Name",
        "memberships": [],
        "profilePicture": "https://img.clockify.me/no-user-image.png",
        "activeWorkspace": "11111111111111111111",
        "defaultWorkspace": "11111111111111111111",
        "settings": {
            ...
        },
        "status": "ACTIVE"
    },
    ...
]

As you can see, memberships is an empty array, and the GO code looks for this data. How do I request it ?


Solution

  • Ok, I just need to pass it as URL part

    curl \
    --request GET \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -H "X-API-KEY:myAPIkey" \
    --url "https://api.clockify.me/api/v1/workspaces/myworkspaceID/users?memberships=ALL"  > ./out.txt