创建使用Wunderlist API任务任务、Wunderlist、API

2023-09-11 22:35:08 作者:华丽凋谢

在了解这个(猜是这样),结束了使用的 Wunderlist API ,它为上市我所有的名单,并列出与给定list_id我所有的任务。现在,我想创建一个任务,赋予了list_id:

 函数create_new_task(){
   list_id = $(#list_id)VAL()。 //检查整数
   。标题= $(#task_title)VAL(); //检查字符串
   $阿贾克斯({
       网址:https://a.wunderlist.com/api/v1/tasks,
       方法:POST,
       的contentType:应用/ JSON的,
       标题:{X-访问令牌:access_token,X-客户ID:CLIENT_ID},
       数据:{list_id形式:parseInt(list_id),头衔:title.toString()}
   }),成功(功能(数据){
       $(#create_new_task_modal)模式(隐藏)。
       SwaI位(任务创造了!,你的任务是创建成功!,成功);
   })错误(handleError的);
}
 

但即时得到一个 400错误的请求与以下非描述性错误:

  {错误:BAD_REQUEST}
 
安卓应用推荐 装个应用 不再忘事儿

任何一个已经做到了这一点,也可以看到我在想什么?

谢谢!

更新:

现在我试着用卷曲和它的作品..不能找到我的$就实现了差异:

 卷曲-H内容类型:应用程序/ JSON-HX-访问令牌:XXX-HX-客户ID:YYYa.wunderlist。 COM / API / V1 /任务-X POST -d{list_id:1234567,称号:hellooo}
 

解决方案

最后!这并获得成功。

显然,我必须设置过程数据:假因为我需要一个字符串发送数据,而不是对象。同样变化的数据为字符串,而不是一个对象。

After understanding this (guess so) and ended up using the Wunderlist API, it worked for listing all my lists and listing all my tasks with a given list_id. Now i'm trying to create a task, given a 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);
}

But im getting a 400 bad request with the following non-descriptive error:

{"error":"bad_request"}

Any one has accomplished this before or can see what am i missing?

Thanks!

Update:

Now im trying to use CURL and it works.. cant find the difference with my $.ajax implementation:

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"}'

解决方案

Finally!, this did the trick.

Apparently i had to set processData: false because i needed to send a string as data, not an object. Also changing data to a string instead of an object.

 
精彩推荐