“无法将\“项目解释为\”项目“中的标识符。

时间:2019-03-20 15:43:43

标签: curl groovy asana

我尝试在groovy脚本中实现curl命令。 目标是确定Asana中的任务。 该命令在命令提示符中可以正常运行,但是当我尝试在groovy脚本中运行它时失败。这是我的命令:

curl -v -H "Authorization: Bearer <myToken>" https://app.asana.com/api/1.0/tasks --data-urlencode "projects=<projectId>" --data-urlencode "notes=message" --data-urlencode "name=null"

我得到的错误是:

{"errors":[{"message":"Could not interpret \"projects as an identifier in \"projects.","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"}]}

我还尝试将命令放入列表中,但是curl尝试将列表的每个部分作为主机解析:

def command = ["curl",
           "https://app.asana.com/api/1.0/tasks",
           "-H","Authorization:","${authorizationToken}",
           "--data-urlencode","projects=","${projects}",
           "--data-urlencode","notes=","${notes}",
           "--data-urlencode","name=","${name}"];

如何在groovy脚本中正确转义data-urlencode参数? 这与groovy运行时有关吗,因为groovy试图不断重建URL?

0 个答案:

没有答案