Python - Wrike API. Creating new tasks (HELP)
Hi,
I am trying to use python to create new tasks in Wrike. I am able to do this successfully but only for very basic fields such as title, description, and status. I am having trouble setting sub dicts, for example {"dates":{"start":"YYYY-MM-DD"}. Here's a sample of my code. When I try to add information for start and due dates I get status code 400.
def main():
folderId = "folderIDnumber"
headers = {'authorization': "bearer my_token_key"}
url = "https://www.wrike.com/api/v3"
data = formWrikeTaskJson(title="new task",
description="some details",
status=postStatus)
rPost = post2wrike(folderId,headers,url,data)
print rPost.status_code
def formWrikeTaskJson(title="New Task",description="",status="Active",customStatusId='',
starttime=datetime.datetime.today().strftime('%Y-%m-%d'),
endtime = datetime.datetime.today().strftime('%Y-%m-%d')):
data = {}
data["title"]=title
data["description"]=description
data["status"]=status
#data["dates"]={"start":starttime} this part does not work!
#data = json.dumps(data) neither does doing this in general
return data
def post2wrike(folderId,headers,url,json):
url = url+"/folders/{}/tasks".format(folderId)
rPost = requests.post(url, headers=headers,data=json)
return rPost