【问题标题】:Creating a new Phabricator task with javascript使用 javascript 创建一个新的 Phabricator 任务
【发布时间】:2018-11-08 17:22:35
【问题描述】:

我正在尝试连接到 Phabricator 管道 API 并通过绑定到谷歌表的 javascript 创建任务。

Conduit API Docs linked here 并没有真正解释太多。我见过更好的 API 文档!

以下是我的想法,但这是一个 cURL,我不知道如何使它成为 Javascript 或枯萎这是否可行?感谢您的帮助

curl https://secure.phabricator.com/api/maniphest.edit \
-d api.token=api-token \
-d param= [
    {
      "type": "title",
      "value": "A value from a cell on the googlesheet"
    },
    {
      "type": "description",
      "value": "A value from a cell on the googlesheet"
    },
    {
      "type": "subscribers.add",
      "value": "A value from a cell on the googlesheet"
    }
  ] \

【问题讨论】:

  • 你发现了吗?

标签: javascript phabricator


【解决方案1】:

一般来说步骤是:

首先,在以下位置生成一个 API 令牌: https://phabricator.yourdomain.com/settings/user/username/page/apitokens/

phabricator.yourdomain.com 必须由您安装了 Phabricator 的子域更改,username 必须由您的管理用户名更改。

那么,假设你在phabricator.yourdomain.com中安装了Phabricator,你可以使用以下类型的URL请求API方法

https://phabricator.yourdomain.com/api/method_name?parameter1=value1&parameter2=value2...

其中method_name 必须替换为此目录中的真实方法的描述符: https://secure.phabricator.com/conduit/

例如,如果要读取任务号125 的内容,生成的API 令牌值为api-svhcp2a3qmgkkjfa5f6sh7cm4joz,请使用maniphest.info 方法完成如下URL:

http://phabricator.yourdomain.com/api/maniphest.info?api.token=api-svhcp2a3qmgkkjfa5f6sh7cm4joz&task_id=125&output=json

可以直接在首选浏览器中测试此 URL,以获取包含任务编号 125 信息的 JSON 响应(确保任务 ID 存在)。 Firefox 甚至会以人类可读的方式显示返回的 JSON。

然后可以将这些工作 URL 插入到 Javascript 中

window.location.href=http://phabricator.yourdomain.com/api/maniphest.info?api.token=api-svhcp2a3qmgkkjfa5f6sh7cm4joz&task_id=125&output=json

或作为异步 Ajax 调用。

【讨论】:

    【解决方案2】:

    我遇到了和你类似的问题(我使用 HTTParty 和 Ruby)。 为了解决它,我使用了以下主体(使用您的示例):

    "transactions[0][type]=title&transactions[0][value][0]=A value from a cell on the googlesheet&transactions[1][type]=description&transactions[1][value]=A value from a cell on the googlesheet&transactions[2][type]=subscribers.add&transactions[2][value][0]=A value from a cell on the googlesheet"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 2012-03-30
      • 2012-08-14
      • 1970-01-01
      • 1970-01-01
      • 2021-04-27
      相关资源
      最近更新 更多