• 1000 там также работает нормально, но в экземпляре, размещенном на клиенте, он не работает и дает ошибку 400, другие apis работают нормально. Найдите мой код ниже. Пожалуйста, предоставьте решение для этого.
final String username = "****";
final String password = "****";
final String proxyUrl = "****";
final int port = 8080;
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(
new AuthScope(proxyUrl, port),
new UsernamePasswordCredentials(username, password)
);
HttpHost myProxy = new HttpHost(proxyUrl, port);
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.setProxy(myProxy).setDefaultCredentialsProvider(credsProvider).disableCookieManagement();
HttpClient httpClient = clientBuilder.build();
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(httpClient);
RestTemplate restTemplate = new RestTemplate(factory);
//Headers
HttpHeaders headers = new HttpHeaders();
String auth = "****" + ":" + "****";
String basicAuth = "Basic " + new String(new sun.misc.BASE64Encoder().encode(auth.getBytes()));
headers.set("Authorization", basicAuth);
headers.set("X-Atlassian-Token", "no-check");
//map
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
FileSystemResource value = new FileSystemResource(new File("D://test.txt"));
map.add("file", value);
HttpEntity<LinkedMultiValueMap<String, Object>> requestEntity = new HttpEntity<>(map, headers);
ResponseEntity<String> d = restTemplate.exchange("https://*******/rest/api/2/issue/***-1/attachments", HttpMethod.POST, requestEntity, String.class);