Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

REST API - 'order by' param is ignored Edited

Jira Cloud

Issue:

REST API is ignoring 'order by' parameter. Following return result in the same order. Filter is: Key IN (PROJ-1, PROJ-2, PROJ-3). Sorting on other fields is ignored as well. Return result is always sorted on descending Key.

  • zzz.atlassian.net/rest/api/3/search?jql=filter=12345&orderBy=key&fields=key
  • zzz.atlassian.net/rest/api/3/search?jql=filter=12345&orderBy=-key&fields=key

Tried this format as well. Same result.

  • zzz.atlassian.net/rest/api/3/search?jql=filter=12345&order+by+key+ASC&fields=key
  • zzz.atlassian.net/rest/api/3/search?jql=filter=12345&order+by+key+DECS&fields=key

Documentation does not mention order as an option. Has this been deprecated or I am making an incorrect request? How can I sort on Key?

Using JQL directly (instead of filter=12345) returned the same result.

Thank you.

1 answer

0 votes
Warren Community Leader May 19, 2021

Hi @Saeed 

I haven't used a filter in an API query, but I feel the issue might be that the sorting should be in the filter itself. Your orderBy statement isn't part of the jql= section and the API call for search doesn't (and never did) support orderBy.

So I believe there are 2 ways to correct this :

  1. Add the orderBy statement into the filter itself
  2. Use the actual JQL query (including orderBy) in the API call

Thank you @Warren. Defining sort key/order in the saved filter is ignored as well. Jira server version ignores order in the saved filter and it is required adding it to the GET params. This, on server version, has worked for the past 4 years for us. We have moved from server to cloud and that does not work anymore.

Per your suggestion, I used the JQL directly in the call. That worked. However, it is not a viable option for us since the saved filter is used in a few places and changes regularly.

One more observation: Using the same saved filter in Google Docs's Atlassian add-on works fine.

I would appreciate all suggestions.

@Warren - Resolved.

"=" in filter=12345 must be encoded.

ORDER BY in GET overrides the one in the saved filter (if any). Correct behavior IMO.

  • Does not work:
    zzz.atlassian.net/rest/api/3/search?jql=filter=12345&order+by+key+ASC&fields=key
  • Works:
    zzz.atlassian.net/rest/api/3/search?jql=filter%3D12345&order+by+key+ASC&fields=key

To be on the safe side, I'm now encoding the entire parameter instead of using +

zzz.atlassian.net/rest/api/3/search?jql=filter%3D12345%20ORDER%20BY%20key%20ASC&fields=key

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you