如何使用ZenHub API设置问题管道 [英] How to set an issue pipeline with ZenHub API

查看:165
本文介绍了如何使用ZenHub API设置问题管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在企业GitHub安装中使用ZenHub。我正在编写一个脚本来将问题从一个GitHub库转移到另一个库,包括ZenHub信息。我已经复制了问题,设置了标签和里程碑。然后我使用ZenHub API来设置估计并创建史诗。所有的工作正常。我的最后一步是将问题分配给ZenHub管道。以下工作正常(获取有关问题的信息):

  zenhub_headers = {X-Authentication-Token:% s'%zenhub_token} 
url ='%s / p1 / repositories /%d / issues / 15'%(zenhub_endpoint,repo)
response = requests.get(url,headers = zenhub_headers,verify = False)

但是,当我试图将相同的问题移动到具有以下内容的管道中时: p>

  params = json.dumps({pipeline_id:5a36d8584b9b9e57bc9729f9})
zenhub_headers = {X-Authentication-令牌:%s%zenhub_token}
url ='%s / p1 / repositories /%d / issues / 15 / moves'%(zenhub_endpoint,repo)
response = requests.post(url ,headers = zenhub_headers,data = params,verify = False)

c $ c> b'{message:pipeline_id的无效字段:undefined}'。我已经验证了管道 5a36d8584b9b9e57bc9729f9 确实存在于目标回购站中。



API仍处于测试阶段。我想知道这是API中的一个错误还是我做错了什么。

解决方案

来自ZenHub的Pablo在这里。这里的问题是请求不是完整的。 position 参数缺失,您不需要将请求主体作为字符串进行编码,您可以直接发送字典:

 导入请求

#不需要字符串化
params = {
pipeline_id:5a36d8584b9b9e57bc9729f9,
position:top
}

#这里省略了一些代码...

response = requests.post(url,headers = zenhub_headers,data = params,verify = False)

移动问题端点的文档可用这里。欢呼声,

We use ZenHub with our enterprise GitHub installation. I'm writing a script to move issues from one GitHub repo to another, including the ZenHub info. I've gotten the issues copied, labels and milestones set. I then use the ZenHub API to set estimates and create epics. All that works fine. My final step is to assign the issues to ZenHub pipelines. The following works fine (to get info about an issue):

zenhub_headers = {"X-Authentication-Token": "%s" % zenhub_token}
url = '%s/p1/repositories/%d/issues/15' % (zenhub_endpoint, repo)
response = requests.get(url, headers=zenhub_headers, verify=False)

However, when I attempt to move the same issue to a pipeline with the following:

params = json.dumps({"pipeline_id": "5a36d8584b9b9e57bc9729f9"} )
zenhub_headers = {"X-Authentication-Token": "%s" % zenhub_token}
url = '%s/p1/repositories/%d/issues/15/moves' % (zenhub_endpoint, repo)
response = requests.post(url, headers=zenhub_headers, data=params, verify=False)

I get a 400 with: b'{"message":"Invalid Field for pipeline_id: undefined"}'. I've verified that pipeline 5a36d8584b9b9e57bc9729f9 does exist in the target repo.

The API is still in a beta state. I'm wondering if this is a bug in the API or something I'm doing wrong.

解决方案

Pablo from ZenHub here. The problem here is that the request is not well-formed. The position parameter is missing, and you don’t need to encode the request body as a string, you can just send the dictionary directly:

import requests

# No need to stringify
params = {
    "pipeline_id": "5a36d8584b9b9e57bc9729f9",
    "position": "top"
}

# some code omitted here...

response = requests.post(url, headers=zenhub_headers, data=params, verify=False)

The documentation of the move issues endpoint is available here. Cheers,

这篇关于如何使用ZenHub API设置问题管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆