创建使用Wunderlist API任务 [英] Creating Task using Wunderlist API

查看:112
本文介绍了创建使用Wunderlist API任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在了解这个(猜是这样),结束了使用的 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.

这篇关于创建使用Wunderlist API任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆