我一直在尝试使用curl调用conduit api来向特定项目添加成员,并编写了以下命令:
curl https://test-caxzj6a226zp.phacility.com/api/project.edit -d api.token=api-token -d transactions=parent -d transactions=项目-phid -d transactions=members.add -d transactions[]=用户-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-项目必须有名称。”}
发布于 2019-12-04 00:12:29
您的调用中有一些错误。首先,您指定了在同一索引中应用的两个事务。稍微格式化一下你的电话,我们就会得到:
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]您实际上可以从conduit应用程序中提交对conduit的测试调用,在提交之后,示例部分中的一个选项卡将显示通过API执行该操作所需的curl调用:
https://secure.phabricator.com/conduit/method/project.edit/

https://stackoverflow.com/questions/59113510
复制相似问题