Skip to content

upgrade to version 3 rest api#467

Closed
freibuis wants to merge 1 commit intosumoheavy:masterfrom
freibuis:master
Closed

upgrade to version 3 rest api#467
freibuis wants to merge 1 commit intosumoheavy:masterfrom
freibuis:master

Conversation

@freibuis
Copy link

@freibuis freibuis commented Aug 27, 2025

Since the atlassian jira api has deprecated jql search via /rest/api/3/search in favour /rest/api/3/search/jql

This pull requests applies changes based on this documentation
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get

This method also handles the loop through records. The previous version required loop start_at > end to get all the data. because the api now requires a nextPageToken and therefore its best to do the issue loop from with in this method.

Old way to get data to query via jql with records greater than 50 results

 jql = "project="abc"
 issues                = []
fields              ||= %w[issuetype id key]
    max_results_per_query = 50
    loop do
      begin
        issues_results = client.Issue.jql(
          jql, {
            fields:      fields,
            max_results: max_results_per_query,
            start_at:    issues.size,
            expand:      expand
          }
        )
      rescue JIRA::HTTPError => e
        raise e unless e.response.code == '400'

        issues_results = []
      end
      issues.push(*issues_results)
      break if issues_results.empty?
    end

new way

 jql = "project="abc"
issues = client.Issue.jql(
  jql, {
    fields:      fields,
    max_results: max_results_per_query,
    expand:      expand
 })

@freibuis
Copy link
Author

tests would need to be updated, but I am having issues getting tests working. I will try again in a couple of days

@fuzzkat
Copy link
Contributor

fuzzkat commented Aug 28, 2025

Possibly the name of this branch is unclear. Atlassian have applied this change to version 2 of the API as well, so perhaps it should be "Use new JQL endpoint with token based paging".

Comment on lines +90 to +94
if options[:fields]
url << "&fields=#{options[:fields].map do |value|
CGI.escape(client.Field.name_to_id(value))
end.join(',')}"
end
Copy link

@levindixon levindixon Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Important to note that the v2 endpoint returns all navigable fields by default whereas the v3 endpoint only returns IDs.

v2

https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-search/#api-rest-api-2-search-get

Note: All navigable fields are returned by default. This differs from GET issue where the default is all fields.

v3

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-get

Note: By default, this resource returns IDs only. This differs from GET issue where the default is all fields.

@freibuis
Copy link
Author

freibuis commented Sep 1, 2025

closing this in favour of #468

@freibuis freibuis closed this Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants