Python scripting Data Migration Expert Needed

Job ID: 38095117

Budget: $10 – $30 AUD

I'm in need of a skilled data migration python specialist to help me move text and attachments data from my current on-premises server to another on-premises server.

Key Requirements:
- Experience with migrating text and attachments from one jira data centre instance to anotyer jira data centre instance
- Proficiency in fetching data from source jira API and posting to target JIRA API
- Ability to ensure the migration is completed securely and efficiently
Fix this program.

import requests
import json

# Source Jira instance
src_jira_url = "(link unavailable)"
src_token = "src_token"

# Destination Jira instance
dst_jira_url = "(link unavailable)"
dst_token = "dst_token"

# Get all issues from source Jira instance
src_issues_url = f"{src_jira_url}/rest/api/2/search"
src_issues_response = requests.get(
src_issues_url,
headers={"Authorization": f"Bearer {src_token}"}
)
src_issues = json.loads(src_issues_response.text)["issues"]

# Iterate over issues and migrate attachments
for issue in src_issues:
issue_key = issue["key"]
print(f"Migrating attachments for issue {issue_key}...")

# Get attachments from source Jira instance
src_attachments_url = f"{src_jira_url}/rest/api/2/issue/{issue_key}/attachments"
src_attachments_response = requests.get(
src_attachments_url,
headers={"Authorization": f"Bearer {src_token}"}
)
src_attachments = json.loads(src_attachments_response.text)

# Upload attachments to destination Jira instance
for attachment in src_attachments:
attachment_file = requests.get(
attachment["content"],
headers={"Authorization": f"Bearer {src_token}"}
)
dst_attachments_url = f"{dst_jira_url}/rest/api/2/issue/{issue_key}/attachments"
dst_attachments_response = requests.post(
dst_attachments_url,
headers={"Authorization": f"Bearer {dst_token}"},
files={"file": attachment_file.content}
)
print(f" * Migrated attachment {attachment['filename']}")
```
Related categories: Python JSON