使用Zenhub API从Github问题创建Epic [英] Creating an Epic from a Github Issue with Zenhub API

查看:536
本文介绍了使用Zenhub API从Github问题创建Epic的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是如何设置一个后续问题使用zenhub发布管道

我试图将问题转换为Python脚本中的史诗。我可以将该问题转换为Epic,但当我在创建史诗时尝试添加问题时出现错误。

这样做:

  zenhub_headers = {X-Authentication-令牌:%s%令牌} 
target_zh_issues_url ='%s / p1 / repositories /%d / issues'%(zh_api_endpoint,target_repo_id)
params = {}
response = requests .post(target_zh_issues_url +'/%s / convert_to_epic'%issue,headers = zenhub_headers,data = params)



<当我设置 params = {issues:[]}



时,代码也可以工作但是当我尝试使用 params = {issues:[{repo_id:280565,issue_number:17}]}添加问题}



我得到一个400错误, b'{message:问题的无效字段:[object Object],[object Object]}'然后我尝试使用 / update_issues API将问题添加到我创建的史诗。

  target_zh_epics_url ='%s / p1 / repositories /%d / epics'%(zh_api_endpoint,target_repo_id)
params = {add_issues:[{repo_id:280565,issue_number:17}]}
response = requests.post(target_zh_epics_url +'/%s / update_issues'%issue,headers = zenhub_headers,data = params)

这导致400错误, b'{message :addIssues的字段无效:repo_id,issue_number}'。这些字段如 API文档中所述。

解决方案

我通过添加'Content-Type':'application / json' / code>到我的头文件并将JSON正文转储为字符串, params = json.dumps({issues:[{repo_id:280565,issue_number:17}] })



我的代码现在看起来像:

  zenhub_headers = {X-Authentication-Token:%s%token,'Content-Type':'application / json'} 
target_zh_issues_url ='%s / p1 / repositories /%d / issue'%(zh_api_endpoint,target_repo_id)
params = json.dumps({issues:[{repo_id:280565,issue_number:17}]})
response = requests.post (target_zh_issues_url +'/%s / convert_to_epic'%issue,headers = zenhub_headers,data = params)

虽然我不确定为什么这个调用带有一些不带字符串的 {issues:[]} 成功了。


This is a follow up question to How to set an issue pipeline with zenhub.

I'm attempting to convert an issue to an epic in a Python script. I can convert the issue to an Epic, but I get an error when I attempt to add issues when creating the epic.

This works:

zenhub_headers = {"X-Authentication-Token": "%s" % token}
target_zh_issues_url = '%s/p1/repositories/%d/issues' % (zh_api_endpoint, target_repo_id)
params = {}
response = requests.post(target_zh_issues_url + '/%s/convert_to_epic' % issue, headers=zenhub_headers, data=params)

The code also works when I set params = {"issues":[]}

But when I attempt to add an issue with params = {"issues": [{"repo_id": 280565, "issue_number": 17}]}

I get a 400 error, b'{"message":"Invalid Field for issues: [object Object],[object Object]"}'

I then tried using the /update_issues API to add issues to the epics I'd created.

target_zh_epics_url = '%s/p1/repositories/%d/epics' % (zh_api_endpoint, target_repo_id)
params = {"add_issues": [{"repo_id": 280565, "issue_number": 17}]}
response = requests.post(target_zh_epics_url + '/%s/update_issues' % issue, headers=zenhub_headers, data=params)

This resulted in a 400 error, b'{"message":"Invalid Field for addIssues: repo_id,issue_number"}'. Those fields are as described in the API doc.

解决方案

I got this to work by adding 'Content-Type': 'application/json' to my headers and dumping the JSON body to a string, params = json.dumps({"issues": [{"repo_id": 280565, "issue_number": 17}]})

My code now looks like:

zenhub_headers = {"X-Authentication-Token": "%s" % token, 'Content-Type': 'application/json'}
target_zh_issues_url = '%s/p1/repositories/%d/issues' % (zh_api_endpoint, target_repo_id)
params = json.dumps({"issues": [{"repo_id": 280565, "issue_number": 17}]})
response = requests.post(target_zh_issues_url + '/%s/convert_to_epic' % issue, headers=zenhub_headers, data=params)

Though I'm not sure why the call with a body of unstringified {"issues":[]} was succeeding.

这篇关于使用Zenhub API从Github问题创建Epic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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