[解决]
怀疑这个问题与我格式化请求的方式有关。由于原因,我不清楚嵌套的custom_fields字典创建的附加级别是不是以正确的JSON格式格式化。我能够使用请求JSON参数解决此问题。
def postTaskToAsana(taskName, taskURL, taskCreated, taskCompleted, taskDue): token = "<TOKEN>" bearerToken = "Bearer " + token header = { "Authorization" : bearerToken } options = { "data" : { "projects" : ["123412341234"], "name" : "Review Task: " + taskName, "notes" : "Please review this task for where the process failed.\nTask: " + taskURL, "assignee" : "123412341234", "followers" : ["123412341234"], "custom_fields" : { "123412341234" : taskCreated, "123412342134" : taskDue, "123412341234" : taskCompleted } } } url = "https://app.asana.com/api/1.0/tasks" r = requests.post(url, headers=header, json=options) return r