I want to upload an attachment using REST to a Jira Service Desk ticket.
I understood, that in order to do that first i must upload a temporary attachment, if that response is OK, i can use the temporaryAttachmentId
to upload the attachment to a ticket.
My problem is that i got the following error:
HttpResponseProxy{HTTP/1.1 415 Unsupported Media Type [Server: Atlassian Proxy/XXX, ATL-vTM-Backend-Time: XX, Content-Type: text/html;charset=UTF-8, Strict-Transport-Security: max-age=XXX; includeSubDomains; preload, Date: XX, X-AREQUESTID: XX, ATL-vTM-Time: XX, X-AUSERNAME: XXXX, X-Content-Type-Options: nosniff, Connection: keep-alive, Set-Cookie: atlassian.xsrf.token=XXXX|lin; Path=/; Secure, X-Seraph-LoginReason: OK, Content-Length: 0, ATL-vTM-Queue-Time: 0] [Content-Type: text/html;charset=UTF-8,Content-Length: 0,Chunked: false]}
My code looks like this (url is a valid url, and the file exists):
HttpPost httpPost = new HttpPost(url);
processHttpEntityEnclosingRequestBase(httpPost, headers);
MultipartEntity entity = new MultipartEntity();
entity.addPart("file", new FileBody(new File(file.getAbsolutePath())));
httpPost.setEntity(entity);
HttpResponse responsePut = httpclient.execute(httpPost);
My headers: [Authorization=Basic XXXXXXX, null, null, null, Accept=application/json, null, null, null, X-Atlassian-Token=nocheck, null, null, null, null, null, null, Content-Type=multipart/form-data]
What could be the problem?
Just a rough guess: your header accept application/json but in the error response the content type is text/html. Maybe that's the problem.