Downloading form

Hello Team,

I am writing a python script to automate some checks. For that I need to download the submitted form from the change ticket and then use the data from the downloaded file to do comparison. I would need the form in json format.
Please check the below code and suggest:

from typing import Any, Dict, Tuple
import json
import requests
import getpass
from opscli.core import kubernetes
from opscli.core import utils
from opscli.core.base_logger import logger
from opscli.core.console import console
from opscli.config import jcloud_env

from rich.table import Table

# Jira credentials and base URL
JIRA_API_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxx'

def prod_push_post_validation(ticket_number):

# Create a session and set basic authentication
session = requests.Session()

# Get the Jira issue details to retrieve attachments
issue_url = f"{JIRA_BASE_URL}/rest/api/2/issue/{ticket_number}"
response = session.get(issue_url)
issue_data = response.json()

if 'fields' in issue_data and 'attachment' in issue_data['fields']:
attachments = issue_data['fields']['attachment']

# After fetching attachments
print("All Attachments:", [attachment['filename'] for attachment in attachments])

# Filter attachments with file names starting with "application" and random characters
filtered_attachments = [attachment for attachment in attachments if attachment['filename'].endswith('Applications')]

print("Issue URL:", issue_url)
print("Filtered Attachments:", [attachment['filename'] for attachment in filtered_attachments])

if filtered_attachments:
for attachment in filtered_attachments:
attachment_id = attachment['id']
attachment_name = attachment['filename']

# Download the attachment
download_url = f"{JIRA_BASE_URL}/secure/attachment/{attachment_id}/{attachment_name}"
response = session.get(download_url)

if response.status_code == 200:
with open(attachment_name, 'wb') as file:
print(f"Downloaded: {attachment_name}")
print(f"Failed to download: {attachment_name}")
print("No matching attachments found.")
print(f"Unable to retrieve attachment data for issue {ticket_number}.")

# Close the session

This is being called like this:

def prod_push_post_validation(
ticket_number: Annotated[str, typer.Option(
help="Enter the Jira Service Management change ticket number"
) -> None:

Output -

All Attachments: ['2023-11-16 1159 - Actions.pdf', '2023-11-16 1159 - Applications.pdf']
Issue URL:
Filtered Attachments: []
No matching attachments found.

Please suggest what is missing here.