Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,558,121
Community Members
 
Community Events
184
Community Groups

Can't get JA API 2.0 to have multiple filters

I am trying to make use of the Jira Align API 2.0 to get some specific Feature data.  I've been using this wiki page to help guide me on the structure of the URLs to get the data:

https://help.jiraalign.com/hc/en-us/articles/360060894632-Supported-API-2-0-Query-Syntax

Unfortunately, there aren't any examples of using multiple filters at the same time, to select both a Program ID and another field.  

Here is my CURL command:

curl -X GET "https://blah.jiraalign.com/rest/align/api/2/Features?$filter=((primaryProgramId%20eq%2058)%20and%20(externalProject%20eq%20'CORE'))&$select=id,title,releaseId,externalKey,externalProject,primaryProgramId,releaseVehicleIds" -H 'Authorization: Bearer user:117' -H 'Accept: application/json'| jq .

I have also tried:

curl -X GET "https://blah.jiraalign.com/rest/align/api/2/Features?$filter=(primaryProgramId%20eq%2058)%20and%20(externalProject%20eq%20'CORE')&$select=id,title,releaseId,externalKey,externalProject,primaryProgramId,releaseVehicleIds" -H 'Authorization: Bearer user:117' -H 'Accept: application/json'| jq .

and

curl -X GET "https://blah.jiraalign.com/rest/align/api/2/Features?$filter=primaryProgramId%20eq%2058%20and%20externalProject%20eq%20'CORE'&$select=id,title,releaseId,externalKey,externalProject,primaryProgramId,releaseVehicleIds" -H 'Authorization: Bearer user:117' -H 'Accept: application/json'| jq .

By looking at the output, I can confirm that neither part of my Filter is being used.

Any ideas how I can make this work?  If I use just one of these at a time, it works as expected, but I need both.

Thanks.

 

2 answers

1 accepted

1 vote
Answer accepted

Ok, I now have a command that works for how I want:

curl -X GET 'https://foo.jiraalign.com/rest/align/api/2/Features?$filter=primaryProgramId%20eq%2058%20and%20jiraProjectKey%20eq%20%27CORE%27&$select=id,title,releaseId,externalKey,jiraProjectKey,primaryProgramId,releaseVehicleIds ' -H 'Authorization: Bearer user:117' -H 'Accept: application/json'| jq .

... {
"id": 16178,
"title": "[ENABLER] feature1",
"releaseId": null,
"externalKey": "CORE-338",
"jiraProjectKey": "CORE",
"primaryProgramId": 58,
"releaseVehicleIds": []
},
{
"id": 16180,
"title": "feature2",
"releaseId": 62,
"externalKey": "CORE-302",
"jiraProjectKey": "CORE",
"primaryProgramId": 58,
"releaseVehicleIds": [
1344
]
}
]

Key seems to be the %27 around the string to compare against.

Kirill Duplyakin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Dec 08, 2021

Awesome!

Yeah seems like there are a few potential issues to do with special characters/ accepted format. Glad you were able to find what works!

0 votes
Kirill Duplyakin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Dec 07, 2021

Hi @Mark Dodrill,

This seems to work for me. Both filters are applied and if they don't overlap, I get an empty list.

  1. You mentioned that you get some results, do they literally have the wrong primaryProgramId and externalProject?
  2. Could you anonymize the results and show them here?
  3. I tried this in Insomnia really quickly, I'm wondering if you could try Postman or Insomnia too, does it give the same results?
  4. Do you have other filter queries that worked ok?
  5. Another thing I noticed is that externalProject field references ADO connector project and it's null if you have Jira connector project (can use jiraProjectKey for Jira).
    As having ADO connector is less common - do you mean to use it?

For reference here's what I tried:

https://testsite.jiraalign.com/rest/align/api/2/features?$filter=primaryProgramId eq 999 and externalProject eq '9'&$select=id,title,releaseId,externalKey,externalProject,primaryProgramId,releaseVehicleIds

Hope we can find out more, curious why it works for me but not in your environment 😅

Kirill Duplyakin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Dec 07, 2021 • edited

Hi @Mark Dodrill

I went ahead and tried Curl as well and ran into the same issue.

What solved it was every single $ sign needs to be escaped using \ in cli. Here's the command that worked in the end:

curl -X GET -H "Authorization: Bearer token" "https://testsite.jiraalign.com/rest/align/api/2/features?\$filter=(primaryProgramId%20eq%20999%20and%20externalProject%20eq%20'9')&\$select=id,title,releaseId,externalKey,externalProject,primaryProgramId,releaseVehicleIds" 

 Hope this helps!

Like Rodrigo Cortez likes this

Hmm, strange.  I added the escapes of $, but made no difference:

curl -X GET 'https://foo.jiraalign.com/rest/align/api/2/Features?\$filter=primaryProgramId%20eq%2058%20and%20externalProject%20eq%20CORE\&\$select=id,title,releaseId,externalKey,primaryProgramId,releaseVehicleIds ' -H 'Authorization: Bearer user:117' -H 'Accept: application/json'| jq . | grep primary

Output is:

"primaryProgramId": 4,
"primaryProgramId": 4,
"primaryProgramId": 4,
"primaryProgramId": 4,
"primaryProgramId": 4,
"primaryProgramId": 4,

Which is wrong.  It should be 58, not 4.  

"externalProject": null,

Should be CORE.

Yes, I can confirm that the data returned does not include the right data for the fields in the filter.

Not sure why I'm having this problem.  I thought it would be easier to get this data in BASH rather than writing a program.  :(

Like Kirill Duplyakin likes this

Doing more trial and error, I think the issue is around how to represent non-numeric values in the comparison (i.e. string comparisons).  This query works correctly and uses both filter values in what it returns and doesn't seem to require special quoting of & or $:

curl -X GET 'https://foo.jiraalign.com/rest/align/api/2/Features?$filter=primaryProgramId%20eq%2058%20and%20releaseId%20eq%2062&$select=id,title,releaseId,externalKey,primaryProgramId,releaseVehicleIds ' -H 'Authorization: Bearer user:117' -H 'Accept: application/json'| jq .

...
{
"id": 17318,
"title": "feature1",
"releaseId": 62,
"externalKey": "CORE-2264",
"primaryProgramId": 58,
"releaseVehicleIds": [
1344
]
},
{
"id": 17327,
"title": "[Design Spike] feature2",
"releaseId": 62,
"externalKey": "CORE-2185",
"primaryProgramId": 58,
"releaseVehicleIds": [
1344
]
},
...

Like Kirill Duplyakin likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events