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.
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.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Mark Dodrill,
This seems to work for me. Both filters are applied and if they don't overlap, I get an empty list.
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 😅
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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. :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
]
},
...
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.