标签:build pre int mep username dig bsp def system
private JSONObject Post(String url, String payload, String username, String password) { RestTemplate template = new RestTemplate(); CredentialsProvider provider = new BasicCredentialsProvider(); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); provider.setCredentials(AuthScope.ANY, credentials); CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider) .useSystemProperties().build(); HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactoryDigestAuth(client); template.setRequestFactory(requestFactory); JSONObject jsonObject = JSONObject.fromObject(payload); System.out.println(JSON.toJSONString(jsonObject)); JSONObject resultObj = template.postForObject(url, jsonObject, JSONObject.class);return resultObj; }
标签:build pre int mep username dig bsp def system
原文地址:https://www.cnblogs.com/chenmz1995/p/10891590.html