1

我正在尝试通过 JIRA rest api 更新问题的 fixVersion。JIRA 版本是 4.4.3#663-r165197。它是由 codehaus 托管的实例,不确定这是否有所作为。

请求如下所示:

  curl -u [用户名]:[密码] -X PUT -H 'Content-type: application/json' \
    -d“http://jira.codehaus.org/rest/api/latest/issue/GEOS-[id]”
{
   “更新”:{
      “修复版本”:[
         {
            “放”:[
               {
                  “名称”:“2.2-beta3”
               }
            ]
         }
      ]
   }
}

但我得到一个 405,方法不允许错误。如果我查看该版本 [1] 的其余 api 文档,这是有道理的。他们似乎表明没有办法以这种方式更新问题。但是,如果我查看最新版本 [2] 的文档,他们似乎表明这是可能的。

所以我想问题是如何在 JIRA 4.4 中以这种方式更新问题?还是不可能?

谢谢!

[1] https://developer.atlassian.com/static/rest/jira/4.4.1.html#id151460

[2] http://docs.atlassian.com/jira/REST/latest/#id165544

4

2 回答 2

2

对于 4.4,您必须使用 SOAP updateIssue 方法。5.0 修复了这个问题。

于 2012-05-17T18:06:40.403 回答
0
Prepare Json data as below(Here java as technology i had used), and pass using put method/API.

public static String generateJson(String customFieldId, Object value,
        String attribute) {

    if (isBlankOrNull(attribute)) {
        return "\"" + customFieldId + "\":" + "\"" + value + "\"";
    } else {
        return "\"" + customFieldId + "\":{\"" + attribute + "\":\"" + ""
                + value + "\"}";
    }
}



    public static int invokePutMethod(String auth, String url, String data) {

            int statusCode = 0;
            try {
                Client client = Client.create();
                WebResource webResource = client.resource(url);
                ClientResponse response = webResource
                        .header("Authorization", "Basic " + auth)
                        .type("application/json").accept("application/json")
                        .put(ClientResponse.class, data);
                statusCode = response.getStatus();
                return statusCode;
            } catch (Exception e) {
                Constants.ERROR.info(Level.INFO, e);
                // vjErrorLog.info(Level.INFO, e);
            }
            return statusCode;
        }

attribute could be key, id, name, value etc,

In case of fix version or components, you may have one more way to prepare json data

    return "\"" + customFieldId + "\":[{\"set\" :[{ \"" + attribute
                        + "\" :" + "\"" + data + "\"}]}]";

and invoke put method with above json data.
于 2016-05-22T14:02:47.250 回答