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"
Are you saying that via your API solution, it works successfully with Form and attachment. However, if someone goes to the portal UI using Forms to create issue, then the operation fails when trying to add the attachment?
Please advise.
Best, Joseph Chung Yin
Hello Joseph. No haha
Via my API solution, it works successfully with the Form and the attachment - the file is correctly associated.
However, when the solving team's partner goes to the portal UI and sees the issue through Forms, they are not able to see the attachment inside the specific form field. The attachment appears only at the issue level.
This can be confusing because the file is technically added to the issue, but it is not displayed within the corresponding field in the form itself.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Gustavo Marques da Silva ,
The one thing I can think of is there a possible permission issue. Have you tried uploading manually with the same user that is use to action the automation action?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great observation, I just tried to upload it through the web portal, and I have no problems with it.
I saw through F12 (dev Tools) that the front is calling an endpoint called "https://api.media.atlassian.com/upload/createWithFiles?hashAlgorithm=sha256"
And then "https://{JIRA_URL}/rest/servicedesk/1/customer/portal/{SERVICE_DESK_ID}/media/upload"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.