使用REST将附件上载到Jira Service Desk

时间:2017-09-02 14:18:30

标签: java rest jira-rest-api multipartentity

我想使用REST将附件上传到Jira Service Desk票证。 我明白,为了做到这一点,我必须首先上传一个临时附件,如果该回复没问题,我可以使用temporaryAttachmentId将附件上传到故障单。

我的问题是我收到以下错误:

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]}

我的代码看起来像这样(url是一个有效的网址,文件存在):

  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);

我的标题: [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 /形状数据]

可能是什么问题?

1 个答案:

答案 0 :(得分:0)

粗略猜测:您的标头接受application / json,但在错误响应中,内容类型为text / html。也许这就是问题所在。