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()
4
4 comments
Spot On Innovative Approach Stellar Advice

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

0
Comment actions Permalink
Spot On Innovative Approach Stellar Advice

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 Become a Wrike expert with Wrike Discover

Darina Wrike Team member Become a Wrike expert with Wrike Discover

0
Comment actions Permalink
Spot On Innovative Approach Stellar Advice

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

0
Comment actions Permalink
Spot On Innovative Approach Stellar Advice

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 🙋🏻‍♀️

Cansu Community Team at Wrike Wrike Product Manager Become a Wrike expert with Wrike Discover

Cansu Wrike Team member Become a Wrike expert with Wrike Discover

0
Comment actions Permalink

Folllowing List for Post: Wrike Information (Folder, Task, Details) in Python
[this list is visible for admins and agents only]

Top
Didn’t find what you were looking for? Write new post