Hi,
I’m trying to get the key information of the project using the project name for one automation that i’m working on in python. It is the first time i’m doing that, so i’m strugling with placing the query parameter “query” correctly.
The definition of “query” parameter in jira api is:
Filter the results using a literal string. Projects with a matching key
or name
are returned (case insensitive).
It is exactly what I need. I can get the list of projects, but I can’t make the filter work. Can someone tell me how is the correct way to place the query parameter on the code below?
# This code sample uses the 'requests' library:
import requests
from requests.auth import HTTPBasicAuth
import json
url = "/rest/api/3/project/search"
auth = HTTPBasicAuth("email@example.com", "<api_token>")
headers = {
"Accept": "application/json"
}
query = {
"query" : 'sample-project', # I'm trying that way, not working.
}
response = requests.request(
"GET",
url,
headers=headers,
auth=auth
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))