【问题标题】:Attachment upload to Jira Service Desk using REST使用 REST 将附件上传到 Jira Service Desk
【发布时间】:2017-09-02 14:18:30
【问题描述】:

我想使用 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是有效的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);

我的标题: [授权=基本 XXXXXXX,null,null,null,Accept=application/json,null,null,null,X-Atlassian-Token=nocheck,null,null,null,null,null,null,Content-Type=multipart/表单数据]

可能是什么问题?

【问题讨论】:

    标签: java rest jira-rest-api multipartentity


    【解决方案1】:

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

    【讨论】:

    • 我期待一个 json 结果
    • 好的。但在例外情况下:“Content-Type: text/html;charset=UTF-8”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-01
    • 1970-01-01
    相关资源
    最近更新 更多