Wrike Information (Folder, Task, Details) in Python
Here is sample python: would be happy to help.
def WrikeResponse (url, querystring):
wrikeurl = 'https://www.wrike.com/api/v4/' + url
payload = ""
headers = {
'Authorization': "Bearer eyJ0dCI6InAiLCJhbGciOiJIUzI1NiIsInR2IjoiMSJ9.eyJkIjoie1wiYVwiOjc4NjMyNSxcImlcIjo2MTQzMTM4LFwiY1wiOjQ1OTMzMjQsXCJ1XCI6MzI1OTkzOSxcInJcIjpcIlVTXCIsXCJzXCI6W1wiV1wiLFwiRlwiLFwiSVwiLFwiVVwiLFwiS1wiLFwiQ1wiLFwiQVwiLFwiTFwiXSxcInpcIjpbXSxcInRcIjowfSIsImlhdCI6MTU1NjMwMjQyMn0.EoAcG1jk2Mr4ecBwl3fPCfucbHbLme4oT7pyZofT8eI",
'cache-control': "no-cache",
}
jsondata = ''
try:
with requests.request("GET", wrikeurl, data=payload, headers=headers, params=querystring) as response:
if response.status_code == 200:
jsondata = response.json()
else:
jsondata = response.status_code
except:
print('Error while fetching data!')
return jsondata
def GetFolders():
url = 'folders'
records = []
querystring = ""
jsondata = WrikeResponse(url, querystring)
for row in jsondata['data']:
item = row['id'], row['title']
records.append(item)
return records
def GetProjectsFromFolder(FolderId):
url = 'folders/' + FolderId + '/tasks'
records = []
querystring = {
'fields': '["subTaskIds","customFields"]',
'descendants': 'true',
'subTasks': 'true',
}
jsondata = WrikeResponse(url, querystring)
for row in jsondata['data']:
item = {'id': row['id'], 'title': row['title'], 'status': row['status'],
'customStatusId': row['customStatusId'], 'dates': row['dates'], 'subTaskIds': row['subTaskIds'],
'customFields': row['customFields']}
records.append(item)
return records
import Wrike
import tkinter as tk
from pandastable import Table
import pandas as pd
allFolders = Wrike.GetFolders()
folderId = [f for f in allFolders if f[1] == "folder name"]
allProjects = Wrike.GetProjectsFromFolder(folderId[0][0])
filteredProjects = [x for x in allProjects if x['status'] == 'Active']
df = pd.DataFrame(allProjects)
df.to_excel(r'C:\Users\PACE\Desktop\export_dataframe.xlsx', index=False, header=True)
root = tk.Tk()
root.title('PandasTable Example')
frame = tk.Frame(root)
frame.pack(fill='both', expand=True)
pt = Table(frame, dataframe=df, showtoolbar=True, showstatusbar=True)
pt.show()
pt.columncolors['A'] = 'red'
pt.columncolors['B'] = 'green'
root.mainloop()
Hi Ravi Singh,
May I ask where did you imported the Wrike library? I tried pip install Wrike but my IDE cannot find it. Also, which part of your code performs the pagination to avoid the 1000 API limit call?
Thanks a lot
Hello Jeremiah de Jesus, hope you don't mind me stepping in to help. You can find the details on pagination here. 🙂
Darina Community Team at Wrike Wrike Product Manager Erfahren Sie mehr über Wrikes leistungsstarke Funktionen und lernen Sie Anwendungsbeispiele kennen
Darina Wrike Team member Erfahren Sie mehr über Wrikes leistungsstarke Funktionen und lernen Sie Anwendungsbeispiele kennen
Hi Darina I am trying to investigate further how to implement it in Python from the link you provided. I was already able to do it in PowerQuery but I am trying to migrate all my codes to Python and the only stumbling block I have is the API query limit of 1000 per page. I am not sure which line of the above Python code can do this. In the addition to that, I am not able to pip install the Wrike library that was imported from the above code that's why I could not test it. Thanks
Hi Jeremiah de Jesus, our Support team will be in touch with you via email in relation to your question. Please let us know if we can help with anything else 🙋🏻♀️
For Jeremiah de Jesus and everyone else. In the example, there are two files and the first one is Wrike.py. The second file refers to the first file (in first row import Wrike), not to the library. My json request also receives 1000 rows, but everything is needed, what should I do? Ravi Singh Thanks for the example!
Hi RDN_Василий Рединский, thank you for asking. I've raised a ticket for you and my colleagues from the support team are in touch with you via email👍🏼
Hello!
Thanks for this example!
How is it possible to do it the opposite direction with Python?
I mean, uploading a table of tasks to tasks folder/project?
Welcome to the Community Toms Strazdiņš 🙂 I can see that one of our Support team specialists has reached out to you about this.
I'll be happy to help if you have any other questions - just let me know 👋
Lisa Community Team at Wrike Wrike Product Manager Become a Wrike expert with Wrike Discover
Lisa Wrike Team member Become a Wrike expert with Wrike Discover