Page cover

๐Ÿ“ Search

Find users assignable to projects

GET /rest/api/{2-3}/user/assignable/multiProjectSearch

Returns a list of users who can be assigned issues in one or more projects. The list may be restricted to users whose attributes match a string.

package main
import (
	"context"
	_ "github.com/ctreminiom/go-atlassian/v2/jira/v3"
	"github.com/ctreminiom/go-atlassian/v2/jira/v2"
	"log"
	"os"
)
func main() {
	/*
		----------- Set an environment variable in git bash -----------
		export HOST="https://ctreminiom.atlassian.net/"
		export MAIL="MAIL_ADDRESS"
		export TOKEN="TOKEN_API"
		Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
	*/
	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 (
		accountID   = ""
		projectKeys = []string{"KP"}
		startAt     = 0
		maxResults  = 50
	)
	users, response, err := atlassian.User.Search.Projects(context.Background(), accountID, projectKeys, startAt, maxResults)
	if err != nil {
		log.Fatal(err)
	}
	log.Println("Response HTTP Code", response.Code)
	log.Println("HTTP Endpoint Used", response.Endpoint)

	for _, user := range users {
		log.Println(user)
	}
}

Find users

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

Returns a list of users that match the search string and property.

Find users with permissions

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

Returns a list of users who fulfill these criteria:

  • their user attributes match a search string.

  • they have a set of permissions for a project or issue.

Last updated

Was this helpful?