I am facing issue related to Search JQL. I am using query (issuefunction in issuesInEpics('key = ABCD-24911') and issuetype=Feature) in Jira Portal it is returning some record but when i am using this query in JiraRestClient it is not working it is returning zero record.
Code Snippet:
String query="issuefunction in issuesInEpics('key = ABCD-24911') and issuetype=Feature";
Integer resultsLength=50,startAt=0;
JiraRestClient.getSearchClient().searchJql(query,resultsLength,startAt,null);
Maven Dependency:
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.atlassian.httpclient</groupId>
<artifactId>atlassian-httpclient-spi</artifactId>
<version>0.17.0-m01</version>
</dependency>
Anyone please help me to find the solution.
Hi
I understand that you are able to run this specific JQL query within Jira, but that trying to run this same query in the JiraRestClient is throwing a 403 error. It is not clear me the exact cause here yet, but from that error message it looks like a bad request.
The JQL you are using here appears to be using a Scriptrunner function for searching. But given the way you are using it in this example, perhaps we can run a similar search without it. I'd be interested to see if you can run the JQL search of
type=Feature AND 'Epic Link'=REGOPS-24911
I am not sure if Scriptrunner is at all a factor here yet, but I have a suspicion that it might be given the function has to use quotes and parenthesis here. Perhaps trying this instead might give us some more information about the problem itself, and it might be an alternative query to find what I think are are the same set of issues you are looking for here.
Please let me know the results.
Andy
Hi Andy Heinzer,
After search this JQL query(
type=Feature AND 'Epic Link'=ABCD-24911
) in Jira It is working but in Jira Rest Api It is showing Exception :
RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={}, errorMessages=[No issues have a parent epic with key or name 'ABCD-24911']}]}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For this query (issuefunction in issuesInEpics('key = ABCD-24911') and issuetype = Feature) it is showing record for jira search but zero record fetching for JIRA Rest API .
Also query like (issuefunction in issuesInEpics("resolution is not empty") and issuetype = Feature) .It is working fine for both Jira Rest API and Jira search.
Please give me any solution for this issue . I am stuck with this issue last two week .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is working fine for below query :
issuefunction in issuesInEpics("resolution is not empty") and issuetype = Feature
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for posting back with more information here. I did some more research on this issue and I think you might find this other post interesting, https://community.developer.atlassian.com/t/rest-api-search-giving-400-bad-request/12889
It seems that when you are searching via the REST API, in some cases you have to use the HTTP verb POST instead of GET. This is noted in the JIRA Server platform REST API reference.
GET vs POST: If the JQL query is too large to be encoded as a query param you should instead POST to this resource.
What I am not clear on is exactly how to do that with the specific REST package you appear to be using here. It looks like it is only using a GET for this endpoint.
Alternatively, I noticed in the last comment there that another users recommends to encode the '=' sign as it could be causing an error in the search. I believe this encodes to a %3D
Since your other working query doesn't have this equals sign, it does seem to lend credence to this idea. See if you can adjust your string from
String query="issuefunction in issuesInEpics('key = ABCD-24911') and issuetype=Feature";
to be more like
String query="issuefunction in issuesInEpics('key%3DABCD-24911') and issuetype%3DFeature";
I replaced the = with %3D. Please try this and let me know the results.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My URL Already Encoded internally by
searchJql function , After encoded URL :
Also I have tried this it is also not fetching records :
issuefunction in issuesInEpics('key%3DABCD-24911') and issuetype%3DFeature
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, what about trying another way to run that same query without the equals sign? Perhaps you can try the syntax of
issuefunction in issuesInEpics('key in (ABCD-24911)') and issuetype in (Feature)
It should return the same results as the equals sign would generate in a JQL query.
Try this and let me know.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andy,
It is also not working . It is fetching zero results.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The fact that we don't get results is not necessarily meaning our JQL query is bad. It could be that this is an authentication or authorization limitation. Search is open within Jira to even unauthenticated users. But those users won't be able to return any issues that they don't have permissions to see.
Perhaps calling the getMyPermissionsRestClient() method could tell us more about the account permissions making this request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
MyPermissionsInput myPer=new MyPermissionsInput("ABCD", null, null, null);
Promise<Permissions> permission=theClient.getMyPermissionsRestClient().getMyPermissions(myPer);
After debug I got the permission for LINK_ISSUE, what does it means can you please tell me.
Permission{id=21, key=LINK_ISSUE, name=Link Issues, description=Ability to link issues together and create linked issues. Only useful if issue linking is turned on., havePermission=false}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That permission is a project level permission. More details in Managing project permissions. That specific permission alone is not sufficient to be able to see issues in Jira. In your case, I would want to make sure that this account has the ability to 'Browse projects' permission in all the projects that you want to get search results back from. Without this permission, the search results for that user account will never return any issues those projects.
Which might make sense here that your query is correct, but the permissions of the account making the request are limiting the search results to zero.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot I fixed that issue. It was a permission issue for specific user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.