Hello everyone!
I'm trying to automate an issue opening through python using the Jira APIs.
The issue which I'm trying to open has a form inside it.
I'm getting successful in upload a file to an issue, but when I try to "link" the attachment into the form field for attachment, I keep receiving an "failed to upload" in the screen 
The flow I'm following: Open an issue, add a blank form to the issue, add a file to the issue, answer the form.
def uploadFilesToIssue(ISSUE_KEY):
url = f"{JIRA_URL}/rest/api/3/issue/{ISSUE_KEY}/attachments"
files = {
"file": open("teste_anexo.xlsx", "rb")
}
headers_anexo = {
"Accept": "application/json",
"X-Atlassian-Token": "no-check"
}
response = requests.post(
url,
headers=headers_anexo,
auth=auth,
files=files
)
if response.status_code == 200:
js_attachments = response.json()
else:
js_attachments = {}
print(f"Erro na função GetAssetsObjectsListByAQL - {response.status_code}, {response.text}")
return js_attachments
It works well!
js_attachments = uploadFilesToIssue(ISSUE_KEY)
file = js_attachments[0]
iso_date = file.get("created")
dt = datetime.strptime(iso_date, "%Y-%m-%dT%H:%M:%S.%f%z")
creation_unix = int(dt.timestamp())
answer = {
"files": [
{
"id": file.get("id"),
"name": file.get("filename"),
"size": file.get("size"),
"type": file.get("mimeType", ""),
"creationDate": creation_unix
}
]
}
It passes, but in the web portal, when I see the form on the issue, the error "failed to upload"