【问题标题】:Updating issue with JIRA rest api 4.4JIRA rest api 4.4 的更新问题
【发布时间】:2012-05-25 06:35:50
【问题描述】:

我正在尝试通过 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

【问题讨论】:

    标签: jira


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:
      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.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-01-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多