我正在使用JIRA的其余API在过滤项目名称和问题类型时检索问题。
当我尝试使用API调用时:
<html ng-app="dbApp">
...
<body>
<div ng-controller="DbController">
...
<!-- Table to show date from database -->
<div class="table-responsive">
<table class="table table-hover">
<tr>
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
<th>Column4</th>
<th>Column5</th>
</tr>
<tr ng-repeat="dbData in dbData">
<td>
<span>{{dbData .Column1}}</span></td>
<td>{{dbData .Column2}}</td>
<td>{{dbData .Column3}}</td>
<td>{{dbData .Column4}}</td>
<td>{{dbData .Column5}}</td>
</tr>
</table>
</div>
</body>
</html>
有效!
但是当我尝试时:
String url3 = "jiraURL/rest/api/2/search?jql=project=GB AND issuetype=Requirement&maxResults=1000";
我得到了 String url3 = jiraURL/rest/api/2/search?jql=project=GB AND issuetype=Product Risk&maxResults=1000";
。
这意味着我的网址错误。我认为错误在于两个单词之间有一个空格,即issuetype。
我已经尝试过使用+代替空格,但这不起作用。 我的第一个电话完美无缺。但我不知道如何解决第二次电话。
答案 0 :(得分:1)
每个参数名称和值都应进行URL编码。然后应将它们与分隔符(“&amp;”或“;”)连接起来。看着
...?jql=project=GB AND issuetype=Product Risk&maxResults=1000
我不确定jql
,project
和issuetype
是否是单独的参数,或者整个字符串是jql
的值。如果是前者,则应使用其URL编码形式(“%20”)替换空格:
...?jql=&project=GB%20AND%20issuetype=Product%20Risk&maxResults=1000
如果是后者,“=”s也应该是URL编码的:
...?jql=project%3DGB%20AND%20issuetype%3DProduct%20Risk&maxResults=1000
答案 1 :(得分:1)
你能试试吗?
try {
String url3 = URLEncoder.encode("jiraURL/rest/api/2/search?jql=project=GB AND issuetype=Product Risk&maxResults=1000", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}