For the complete documentation index, see llms.txt. This page is also available as Markdown.
Page cover

๐Ÿ“ŒSearch

This resource represents various ways to search for issues. Use it to search for issues with a JQL query and find issues to populate an issue picker.

Search for issues using JQL (GET)

GET /rest/api/{2-3}/search

Searches for issues using JQL. If the JQL query expression is too large to be encoded as a query parameter, use the POST version of this resource.

package main

import (
	"context"
	"github.com/ctreminiom/go-atlassian/v2/jira/v2"
	"log"
	"os"
)

func main() {

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	atlassian, err := v2.New(nil, host)
	if err != nil {
		log.Fatal(err)
	}

	atlassian.Auth.SetBasicAuth(mail, token)

	var (
		jql    = "order by created DESC"
		fields = []string{"status"}
		expand = []string{"changelog", "renderedFields", "names", "schema", "transitions", "operations", "editmeta"}
	)

	issues, response, err := atlassian.Issue.Search.Get(context.Background(), jql, fields, expand, 0, 50, "")
	if err != nil {
		log.Fatal(err)
	}

	log.Println("HTTP Endpoint Used", response.Endpoint)

	log.Println(issues.Total)

	for _, issue := range issues.Issues {
		for _, history := range issue.Changelog.Histories {

			for _, item := range history.Items {
				log.Println(issue.Key, item.Field, history.Author.DisplayName)
			}
		}
	}

	for _, issue := range issues.Issues {
		for _, transition := range issue.Transitions {
			log.Println(issue.Key, transition.Name, transition.ID)
		}
	}
}

Search for issues using JQL (POST)

POST /rest/api/{2-3}/search

Searches for issues using JQL. There is a GET version of this resource that can be used for smaller JQL query expressions.

Check issues against JQL

POST /rest/api/{2-3}/jql/match

Checks whether one or more issues would be returned by one or more JQL queries.

Last updated

Was this helpful?