0

我想通过使用 JIRA 提供的 REST API 在 JIRA 中创建一个问题。我能够创建一个简单的问题,

使用这个:

   http://localhost:8080/rest/api/latest/issue

和数据如下:

   {"fields":{"project":{"key": "TES"},"summary":"user name not showing validation message","description":"Hi validation is missing from user name","issuetype": {"name": "Bug"},"reporter":{"name":"BruceWayne"}  }}

这运行良好。

现在我想在创建问题时添加 3 个自定义字段。自定义字段是 Authorname、AuthorTag、AuthorID。我怎么能在rest api中做到这一点。我应该在我的数据中添加什么。

我的样本数据如下:-

   {"fields":{"project":{"key": "TES"},"summary":"my bugs 5","description":"Hi","issuetype": {"name": "Bug"},
       "customfield_10000":"roach@yahoo.com",
       "customfield_10100":{"value":"abc"},
       "reporter":{"name":"amit"},
       "components": [{
                 "add" : {"name" : "abc"}
                }],"priority": {
 "id": "1"
  }

      }}

我想使用为 customfields 而不是 customfield_XXXXX 指定的名称。

我想到的一种方法是在创建一个简单的问题后点击 API(使用另一个 API 点击获取元数据,如下所示)

 http://localhost:8080/rest/api/latest/issue/tes-79?expand=editmeta

然后进行 json 解析并再次发出 put 命令以更新同一问题中的字段

但我正在寻找一种在单个 API 命中的方法(同时创建问题)

4

2 回答 2

1

它应该就像设置任何其他字段一样,但您必须使用字段名称“customfield_NNNNN”

于 2014-07-22T16:03:14.557 回答
0

我知道现在回答这个问题已经很晚了,但是如果在撰写本文时不是 OP,那么可能会对其他人有所帮助。

如果你对创建有疑问,那么你可以做这样的事情 - 尝试一个GET你宁愿使用新参数手动创建的问题,然后根据相同的输出,你可以决定更新它带有带有新名称或老式customfield_xxx字段的新参数。

试试GET这样cURL

curl -D- -u fred:fred -X GET -H "Content-Type: application/json" https://jira.fred.com/rest/api/2/issue/FRD-88651

然后你可能会POST像之前所做的那样做:

http://localhost:8080/rest/api/latest/issue
于 2018-02-04T06:02:01.037 回答