2017-09-02 104 views
0

我想使用REST将附件上载到Jira Service Desk票证。 我明白了,为了做到这一点,我必须首先上传一个临时附件,如果该响应正常,我可以使用temporaryAttachmentId将附件上传到票证。使用REST将附件上载到Jira服务台

我的问题是,我得到了以下错误:

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

我的头: 内容类型= multipart/null,null,null,X-Atlassian-Token = nocheck,null,null,null,null,null,null,null null,null,Accept = application/json,表格数据]

可能是什么问题?

回答

0

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

+0

我期待一个json作为结果 –

+0

好的。但是在例外情况下:“Content-Type:text/html; charset = UTF-8” –

相关问题