有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何向github API上的checkruns发送post请求,并使用自定义头?

阅读Github的API,它需要一个自定义的头:“vnd.Github.antiope preview+json”;使用弹簧靴

我总是得到415个不受支持的媒体类型,尽管这是GithubAPI页面中提到的

HttpHeaders headers = new headers.setAccept(Collections.singletonList(new MediaType("application","vnd.github.antiope-preview+json")));
headers.setContentType();
HttpEntity<String> entity = new HttpEntity<>(str,headers);
restTemplate.exchange(url, HttpMethod.POST, entity, String.class);

作为参考,我用同样的标题在《邮差》上做了这件事


共 (0) 个答案