Hey folks, I need some help with the Jira REST API. I used to use JIRA.project_versions(id) to get all the releases for a project. Now I’m switching to the requests library and I’m a bit lost.
For fetching project versions in Jira using the REST API, you’ll want to use the ‘/rest/api/2/project/{projectIdOrKey}/versions’ endpoint. Here’s a Python snippet that should work:
import requests
url = f'https://your-domain.atlassian.net/rest/api/2/project/{project_key}/versions'
response = requests.get(url, auth=(username, api_token))
if response.status_code == 200:
versions = response.json()
for version in versions:
print(f"Version: {version['name']}, ID: {version['id']}")
else:
print(f"Error: {response.status_code}, {response.text}")
This will fetch all versions for the specified project. If you have a large number of versions, you might need to implement pagination by adding ‘startAt’ and ‘maxResults’ parameters to your request. The response includes useful metadata about each version, such as release dates and descriptions.
hey ethan, for project versions try this endpoint:
‘/rest/api/2/project/{projectIdOrKey}/versions’
replace {projectIdOrKey} with ur project’s ID or key. no need for params, it’ll fetch all versions. if u need pagination, add ‘startAt’ and ‘maxResults’ params like u did for issues.
hope this helps! lemme kno if u need anything else
You can then iterate through the results, increasing ‘startAt’ until you’ve fetched all versions. Remember to handle rate limits and potential errors in your code. Good luck with your implementation!