Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to send a scriptrunner jql over JIRA's REST API

Adrian Popescu August 29, 2019

Hello,

I'm trying to send a more complex JQL over rest api currently testing in postman and I cannot seem to get the end of it with formatting to keep the escape characters of the jql in place properly. Whenever I manage to fix the jquery to be valid, I get a jql error and the other way around as well.

Any chance anyone could help with this or did anyone find a way around stuff like this?

Thank you!

 

JSON (The point where I got it to and I don't know anymore thinsg to try with it):
{
"jql": "project = \"PROJECT\" AND issuefunction in parentsOf(\"issueFunction in subtasksOf(\\\"issuefunction in parentsOf('type in subTaskIssueTypes() and status != Resolved and component = ABC') and status = 'Status' and type = 'Issue Type'\\\")\") ORDER BY \"Start date\" DESC\"",
"startAt": 0,
"maxResults": 1,
"fields": [
"issuekey"
]
}

The exact jql that functions in jira and needs to be sent on the api:

project  = "PROJECT" AND issuefunction in parentsOf("issueFunction in subtasksOf(\"issuefunction in parentsOf('type in subTaskIssueTypes() and status != Resolved and component = ABC') and status = 'Status' and type = 'Issue Type'\")") ORDER BY "Start date" DESC

 

1 answer

1 accepted

1 vote
Answer accepted
jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2019

Hey 

I am not sure how you are sending this JQL. It's always easier to form the rest api url after executing the JQL. 

My url after executing in JIRA:

 https://myinstance.com/issues/?jql=project%20%3D%20META

My rest api URL would be: 

https://myinstance.com/rest/api/2/search?jql=project%20%3D%20META 

Let me know if this helped

Adrian Popescu August 29, 2019

Hey @jira guy ,

I'm trying to send that json with post to - https://jira.vidaxl.com/rest/api/2/search

What you're saying does help, but I'm trying to fetch only 1 result per call, only with the "issuekey".

If I'm making a GET request on the rest api url after executing the jql string, I get default max results 50.

Any idea on that one?

Also, thanks a lot, it did help me move forward one step at least.

jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2019

Use pagination. You can limit the results and loop through using startAt param. You can also end the search by comparing the total.

https://myinstance.com/rest/api/2/search?jql=project%20%3D%20META&maxResults=10&startAt=2 

 

Check out the rest api documentation for more info

https://docs.atlassian.com/software/jira/docs/api/REST/8.2.4/

Like Adrian Popescu likes this
Adrian Popescu August 29, 2019

No idea why I didn't take into consideration including everything in the url, since I did look into the API documentation from the start. Thanks a lot for the help! 

I also added "&fields=issuekey" and it returned exactly what I was struggling to achieve through POST. Better open my eyes more next time.

Like jira guy likes this
jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 29, 2019

It happens :)

Make sure to accept the answer that helped. So others in the community can benefit. 

Edit: nevermind :p

Like Adrian Popescu likes this
Adrian Popescu August 29, 2019

Hehe, it's ok. Ofc I would accept the answer, I was just taking the ridiculously hard way and you just pointed the obvious which I overlooked.

Thank you!

Suggest an answer

Log in or Sign up to answer