使用Curl创建具有成员资格的Asana任务

时间:2016-03-04 19:58:40

标签: curl asana-api

我正在尝试使用Debian命令行上的curl创建Asana任务。我将任务分配给特定项目和该项目中的特定部分。我的curl命令创建一个任务,直到我添加"成员资格"参数。这是参数的样子。

-d "memberships=[{project:{id:96927952190628},section:{id:96927952190688}}]"

这是完整的命令(删除了一些隐私信息):

curl -H 'Authorization: Bearer <id>' https://app.asana.com/api/1.0/tasks -d "assignee=me" -d "name=New Task" -d "completed=false" -d "workspace=923066726484" -d "memberships=[{project:{id:96927952190628},section:{id:96927952190688}}]"

这似乎符合基于此处所述的Asana API的要求:https://asana.com/developers/api-reference/tasks#create(请参阅&#39;成员资格&#39;字段定义中的示例)。

当我执行此命令时,Asana返回以下json。

{"errors":[{"message":"memberships: [0]: project: Missing required field","help":"For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"}]}

那么,我做错了什么?

谢谢!

1 个答案:

答案 0 :(得分:2)

在我看来,你需要传递项目:96927952190628而不是项目:{id:96927952190628}(同样适用于部分)

请注意,这仅适用于创作。

示例(替换数字和标记):

卷曲-H&#34;授权:持票人0 / YOURPAT&#34; -X POST&#34; https://app.asana.com/api/1.0/tasks&#34; -H&#34; content-type:application / json&#34; -d&#34; {\&#34; data \&#34;:{\&#34; workspace \&#34;:12,\&#34; name \&#34;:\&#34 ;测试\&#34;,\&#34;会员资格\&#34;:[{\&#34; project \&#34;:123,\&#34; section \&#34;:1234} ]}}&#34;