GET Tasks in Python
I'm getting a good (and correct) response in Postman, but cannot get the right response in Python for Tasks with fields.
[Note: I've gotten other queries to work in Python, like folders and tasks without fields noted below.]
The "fields" parameter seems to be the issue. To be clear the Python below works with "fields" completely removed.
https://www.wrike.com/api/v4/tasks?descendants=true&sortField=CreatedDate&subTasks&fields=["description","parentIds","responsibleIds","superTaskIds","attachmentCount","dependencyIds","authorIds","sharedIds","recurrent","subTaskIds","customFields","hasAttachments","metadata","briefDescription","superParentIds"]
I've not been able to get my Python or the Postman Python Request Snippet to work:
------------------------------------------------------------------------------------------------------------------------
import requests
url = "https://www.wrike.com/api/v4/tasks"
querystring = {"descendants":"true","sortField":"CreatedDate","subTasks":"","fields":"[%22description%22,%22parentIds%22,%22responsibleIds%22,%22superTaskIds%22,%22attachmentCount%22,%22dependencyIds%22,%22authorIds%22,%22sharedIds%22,%22recurrent%22,%22subTaskIds%22,%22customFields%22,%22hasAttachments%22,%22metadata%22,%22briefDescription%22,%22superParentIds%22]"}
payload = ""
headers = {
'Authorization': "Bearer <Token Redacted>",
'cache-control': "no-cache",
}
response_task = requests.request("GET", url, data=payload, headers=headers, params=querystring)
------------------------------------------------------------------------------------------------------------------------
Python Error in Terminal (also in txt file):
{"errorDescription":"Fields parameter value '%22description%22' not allowed","error":"invalid_parameter"}
When I remove the "description", the next Fields parameter is the error:
{"errorDescription":"Fields parameter value '%22parentIds%22' not allowed","error":"invalid_parameter"}
I'd be grateful for some pointers as I'm pretty new to this, and especially dealing with APIs and RESTful.
Hi Steve,
I noticed you have extra quotes around the comma between subTasks and fields. Also, I'm not sure what the %22 is for, but I think something like this should work.
In API v4, the input scheme can be done like this. Here I am using title or permalink to search for a specific ticket, but it can be expanded as needed. The relevant part is that fields cannot be inputed as Ahmed suggested, rather it has to be a string (in python) as shown in my params variable. Params is equivalent to querystring in the questions above.