Hi,
I'm trying to post attachment to Jira Sofware Cloud using system.net.httpClient
Jira documentation :
(https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post)
I'm using the following code :
def addAttachment(domain, filepath, issue, user, passwd):
baseurl = "https://" + domain + "/" + str(issue) + "/attachments"
headers = {
"Accept": "application/json",
"X-Atlassian-Token": "no-check",
}
payload = filepath
client = system.net.httpClient()
response = client.post(baseurl, username=user, password=passwd, file=payload, headers=headers)
if response.good:
return str(response) + " | " + response.text
else :
return str(response) + " | " + response.text
resulting in the following error :
..atlassian.net/rest/api/3/issue/10334/attachments' [400]> | {"message":"org.apache.commons.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is application/octet-stream","status-code":500,"stack-trace":""}
It seems like the file parameter is not fully compliant with what Jira is waiting for.
Could you help me solving this issue ?
Thank you in advance
Guillaume