2012-05-17 85 views
1

我试图通过JIRA rest api更新问题的fixVersion。 JIRA版本是4.4.3#663-r165197。这是由codehaus主办的实例,不知道这是否有所作为。JIRA rest api的更新问题4.4

请求看起来像:

 
    curl -u [username]:[password] -X PUT -H 'Content-type: application/json' \ 
    -d "http://jira.codehaus.org/rest/api/latest/issue/GEOS-[id]" 
 
{ 
    "update":{ 
     "fixVersions":[ 
     { 
      "set":[ 
       { 
        "name":"2.2-beta3" 
       } 
      ] 
     } 
     ] 
    } 
} 

但我得到一个405,方法不允许的错误。如果我查看该版本的其余api文档,这是有道理的[1]。他们似乎表示无法以这种方式更新问题。如果我看看最新版本的文档[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

回答

1

对于4.4你必须使用SOAP updateIssue方法。 5.0修复了这个。

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. 
相关问题