当前位置: 首页 > 知识库问答 >
问题:

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

闾丘树
2023-03-14

我想使用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]}
  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);

共有1个答案

督辉
2023-03-14

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

 类似资料:
  • 我的nexus公开了一个REST API来上传文件。通过curl,我可以使用以下命令上传: 卷曲-X柱“http://myurl:9086/service/rest/v1/components?repository=ebooks-store“-H”accept:application/json“-H”内容类型:multipart/form data“-F”raw。目录=测试“-F”原始。asset

  • 问题内容: 实际上,我正在使用带有Angular 2编码的接口的Spring REST API。 我的问题是我无法使用Angular 2上传文件。 我在Java中的Webresources是: 当我通过带有Auth标头等的URL请求调用它时(它具有适用于Chrome的Advanced Rest Client扩展),它完全可以正常工作 证明:(在这种情况下,一切正常) Spring配置文件和Pom依

  • 附注。当我使用@requestParam(Name=“file”,required=true)MultipartFile文件时,我得到错误POST http://localhost:8080/single-file 400(错误请求),看起来spring无法从FormData获得MultipartFile文件。在后端,我没有得到任何错误,只有MultipartFile文件=null

  • 根据SkyDrive api(http://msdn.microsoft.com/en-us/library/live/hh826531.aspx#uploading_files),我在帖子请求的正文中以字节[]传递图像的内容。文件创建发生在skyDrive服务器上,但当我在skyDrive中打开它时,它说“文件应用程序被损坏或损坏”。 请求的正文 --A300x内容处理:表单数据;name=“f

  • 我尝试使用C#将文件上传到FTP服务器。文件已上传,但字节为零。

  • 我正试图将一个大的(>4MB)附件上载到Office365中的现有邮件中。我遵循以下说明:https://docs.microsoft.com/en-us/graph/outlook-large-attachments?tabs=http 我已经成功创建了上传会话,并获得了一个看起来合法的uploadUrl值,它与文档中的示例大致匹配。然后,我开始对这个url进行PUT操作,用于我选择的第一个字节