я хочу использовать следующие API-интерфейсы Bitbucket PUT в java-коде для фиксации файла build.info https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-rest.html#idm8297049152 ниже - мой java-код
URL url;
try {
url = new URL("http://mybitbuckethost/rest/api/1.0/projects/myproject/repos/myrepo/browse/etc/build.info");
HttpURLConnection hurl = (HttpURLConnection) url.openConnection();
byte[] encodedAuth = Base64.getEncoder().encode(("username"+":"+"password").getBytes());
hurl.setRequestProperty("Authorization", "Basic " + new String(encodedAuth));
hurl.setRequestMethod("PUT");
hurl.setDoOutput(true);
hurl.setRequestProperty("branch","master");
hurl.setRequestProperty("message","just a message");
hurl.setRequestProperty("content", "C:\\somefolder\\build.info");
hurl.setRequestProperty("sourceCommitId", "commit-id");
hurl.setRequestProperty("Content-Type", "application/json");
hurl.setRequestProperty("Accept", "application/json");
if (hurl.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP Error code : " + hurl.getResponseCode());
} else {
System.out.println(hurl.getResponseCode());
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
я получаю код ответа 415 следующим образом
java.io.IOException: Server returned HTTP response code: 415 for URL: http://mybitbuckethost/rest/api/1.0/projects/myproject/repos/myrepo/browse/etc/build.info