Hi, I am following the tutorial:
https://bitbucket.org/atlassian/atlassian-connect-spring-boot/src/master/
I can now make an API request simply without search
and jql
queries like:
@GetMapping(value = "/issue/{issueKey}")
@ContextJwt
@ResponseBody
public String getIssueByIssueKey(@PathVariable String issueKey) throws JsonProcessingException {
String preEncodedUriString = apiPrefix + "/issue/"+issueKey;
UriComponents uriComponents = UriComponentsBuilder.fromUriString(preEncodedUriString).build(true);
return atlassianHostRestClients.authenticatedAsAddon().getForObject(uriComponents.toUri(), String.class);
}
However, it throws errors if I make an API request like /rest/api/3/search?jql=startAt=0&maxResults=100
. I tried to convert all the =
into %3D
or the &
into %26
or both but none of them works.
I found the [ACSPRING-150] - Ecosystem Jira in the tutorial above, however, it seems not working as well. Please let me know if u need more information.
private final String apiPrefix = "/rest/api/3";
@GetMapping(value = "/issues")
@ContextJwt
@ResponseBody
public List<IssuesModel> getAllIssues() throws JsonProcessingException {
String preEncodedUriString = apiPrefix + "/search?jql%3D";
int total = 200;
int startAt = 0;
int maxResult= 100;
List<IssuesModel> issues = new ArrayList<>();
while (startAt<total){
total=300;
String jqlQuery = "project%3DTESTstartAt%3D"+ startAt +"%26maxResults%3D"+maxResult;
// String jqlQuery = "project=TESTstartAt="+ startAt +"&maxResults="+maxResult;
UriComponents uriComponents = UriComponentsBuilder.fromUriString(preEncodedUriString+jqlQuery).build(true);
System.out.println(uriComponents);
System.out.println(uriComponents.toUri());
IssueJqlQueryCollection issueJqlQueryCollection = atlassianHostRestClients.authenticatedAsAddon().getForObject(uriComponents.toUri(), IssueJqlQueryCollection.class);
assert issueJqlQueryCollection != null;
System.out.println(startAt);
issues.addAll(issueJqlQueryCollection.getIssues());
startAt+=maxResult;
}
System.out.println(issues.size());
return issues;
// return atlassianHostRestClients.authenticatedAsAddon().getForObject(uriComponents.toUri(), String.class);
}
pom.xml(part)
<atlassian-connect-spring-boot.version>3.0.3</atlassian-connect-spring-boot.version>
<dependency>
<groupId>com.atlassian.connect</groupId>
<artifactId>atlassian-connect-spring-boot-starter</artifactId>
<version>${atlassian-connect-spring-boot.version}</version>
</dependency>
<dependency>
<groupId>com.atlassian.connect</groupId>
<artifactId>atlassian-connect-spring-boot-jpa-starter</artifactId>
<version>${atlassian-connect-spring-boot.version}</version>
</dependency>