使用奇妙清单创建任务 API

Creating Task using Wunderlist API

在理解 this (guess so) and ended up using the Wunderlist API 之后,它可以列出我所有的列表并列出我所有的任务 list_id。现在我正在尝试创建一个任务,给定 list_id:

function create_new_task(){
   list_id = $("#list_id").val(); //Checked for an integer
   title = $("#task_title").val(); //Checked for a string
   $.ajax({
       url: 'https://a.wunderlist.com/api/v1/tasks',
       method: 'POST',
       contentType: 'application/json',
       headers: { 'X-Access-Token': access_token, 'X-Client-ID': client_id },
       data: {"list_id": parseInt(list_id), "title": title.toString() }
   }).success(function(data){
       $("#create_new_task_modal").modal('hide');
       swal("Task created!", "Your task was successfully created!", "success");
   }).error(handleError);
}

但我得到一个 400 bad request 并出现以下非描述性错误:

{"error":"bad_request"}

任何人以前完成过这个或者可以看到我错过了什么?

谢谢!

更新:

现在我正在尝试使用 CURL 并且它有效.. 找不到与我的 $.ajax 实现的区别:

curl -H "Content-Type: application/json" -H "X-Access-Token: XXX" -H "X-Client-ID: YYY" a.wunderlist.com/api/v1/tasks -X POST -d '{"list_id":1234567,"title":"hellooo"}'

终于!this成功了。

显然我必须设置 processData: false 因为我需要发送一个字符串作为数据,而不是一个对象。还将数据更改为字符串而不是对象。