Skip to content

Latest commit

 

History

History
72 lines (51 loc) · 2.4 KB

Clockify_Update_client.md

File metadata and controls

72 lines (51 loc) · 2.4 KB



Template request | Bug report | Generate Data Product

Tags: #clockify #client #create #api #rest #documentation

Author: Florent Ravenel

Description: This notebook will show how to update a client using Clockify API from a specific workspace.

References:

Input

Import libraries

import requests
import naas

Setup Variables

  • api_key: Get your API key
  • workspace_id: ID of the workspace
  • client_id: ID of the client to get
  • client_data: data to be updated
api_key = naas.secret.get("CLOCKIFY_API_KEY") or "YOUR_API_KEY"
workspace_id = "626f9e3b36c2670314c0386e" #"<WORKSPACE_ID>"
client_id = "626ff141e7dfba353xxxxxx"
client_data = {
    'name': 'xxxxx',
    'email': None,
    'address': None,
    'archived': False,
    'note': 
}

Model

Update client

def update_client(workspace_id, api_key, client_id, client_data):
    url = f"https://api.clockify.me/api/workspaces/{workspace_id}/clients/{client_id}"
    headers = {
        "X-Api-Key": api_key,
        "Content-Type": "application/json"
    }
    response = requests.put(url, headers=headers, json=client_data)
    return response

Output

Display result

response = update_client(workspace_id, api_key, client_id, client_data)
if response.status_code == 200:
    print(f"✅ Client '{client_id}' update from workspace.")
else:
    print(f"❌ Error retrieving client")
response.json()