【问题标题】:Curl command for conduit API管道 API 的 curl 命令
【发布时间】:2023-03-31 12:33:01
【问题描述】:

我一直在尝试使用 curl 调用管道 api 以将成员添加到特定项目并编写以下命令:

curl https://test-caxzj6a226zp.phacility.com/api/project.edit -d api.token=api-[token] -d transactions[0][type]=parent -d transactions[0][value]=[project-phid] -d transactions[0] [type]=members.add -d transactions[0][value][]=[user-phid]

我已按照https://secure.phabricator.com/conduit/method/project.edit/ 上的说明进行操作,并且能够查询 project.search 和 user.search。但是 project.edit 给我带来了麻烦。任何帮助将不胜感激。

PS:我收到以下错误:{"result":null,"error_code":"ERR-CONDUIT-CORE","error_info":"验证错误:\n - 项目必须有名称。"}

【问题讨论】:

  • 你能发布运行 curl 命令的错误是什么吗?
  • 这是错误:{"result":null,"error_code":"ERR-CONDUIT-CORE","error_info":"验证错误:\n - 项目必须有名称。" }
  • 您的 curl 请求命令似乎缺少某些内容,请仔细查看每个输入并找出缺少的内容以及错误所在

标签: go phabricator


【解决方案1】:

您的通话中有一些错误。第一个是您指定要在同一索引中应用的两个事务。稍微格式化你的调用,我们得到:

curl https://test-caxzj6a226zp.phacility.com/api/project.edit \
    -d api.token=api-[token] \
    -d transactions[0][type]=parent \
    -d transactions[0][value]=[project-phid] \
    -d transactions[0][type]=members.add \
    -d transactions[0][value][]=[user-phid]

transactions[0] 有两个定义,如果要应用多个转换,则需要增加索引:

curl https://test-caxzj6a226zp.phacility.com/api/project.edit \
    -d api.token=api-[token] \
    -d transactions[0][type]=parent \
    -d transactions[0][value]=[project-phid] \
    -d transactions[1][type]=members.add \
    -d transactions[1][value][]=[user-phid]

现在,您实际上并没有提到要更改父项目,所以我要删除该事务。

curl https://test-caxzj6a226zp.phacility.com/api/project.edit \
    -d api.token=api-[token] \
    -d transactions[0][type]=members.add \
    -d transactions[0][value][]=[user-phid]

要添加的用户也是一个数组,因此您需要为该参数指定一个索引:

curl https://test-caxzj6a226zp.phacility.com/api/project.edit \
    -d api.token=api-[token] \
    -d transactions[0][type]=members.add \
    -d transactions[0][value][0]=[user-phid]

您可以使用-d transactions[0][value][1]=[user-phid]-d transactions[0][value][2]=[user-phid] 等添加其他用户。

最后,您还需要指定要将成员添加到哪个项目,因为它是必填字段。为此,请指定项目的数字 ID(您可以在其 URL /project/view/1/ 中找到它)、其 PHID 或其名称/slug。

curl https://test-caxzj6a226zp.phacility.com/api/project.edit \
    -d api.token=api-[token] \
    -d transactions[0][type]=members.add \
    -d transactions[0][value][0]=[user-phid] \
    -d objectIdentifier=[project-phid]

您实际上可以从管道应用程序中向管道提交测试调用,提交后,示例部分中的选项卡之一将显示通过 API 执行该操作所需的 curl 调用:

https://secure.phabricator.com/conduit/method/project.edit/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-18
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 2023-03-23
    • 2018-01-01
    • 2016-03-25
    相关资源
    最近更新 更多