通过其 api 将文件上传到 Redmine

问题描述

我想通过 redmine-api文件附加到问题。但是,如果我运行我的方法,我会收到一个 private void uploadFiletoDemoRedmine304651() { String plainCredentials = "TestTheAPI:Qwert5678"; String base64Credentials = new String(Base64.getEncoder().encode(plainCredentials.getBytes())); String authorizationHeader = "Basic " + base64Credentials; try { HttpRequest request = HttpRequest.newBuilder() .uri(new URI("http://demo.redmine.org/uploads.json?filename=dummy.txt" )) .header("Authorization",authorizationHeader) .header("Content-Type","application/octet-stream") .POST(BodyPublishers.ofFile(Paths.get(String.valueOf(getClass().getResource("/dummy.txt"))))) .build(); HttpResponse<String> response = HttpClient.newBuilder().build().send(request,HttpResponse.BodyHandlers.ofString()); System.out.println(response.statusCode()); System.out.println(response.body()); } catch (URISyntaxException e) { System.out.println("Ye,it ain't working my man."); } catch (IOException e) { System.out.println("ups,not what you wanted huh?"); } catch (InterruptedException e) { System.out.println("DON'T INTERRUPT ME WHEN I'M SENDING"); } }

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution Failed for task 'Main.main()' <36 internal lines>
Process 'command 'C:/Program Files/Amazon Corretto/jdk15.0.2_7/bin/java.exe'' finished with non-zero exit value 1 <101 internal lines>

因为这个话题对我来说在 Java 中很陌生,所以我寻求你的帮助。

有人可以向我解释一下,我做错了什么吗?


堆栈跟踪:

{{1}}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...