PostMan添加Authorization验证
JAVA代码实现
String url ="URL路径";
Map prarms = new HashMap<>();
prarms.put("userName","案例");
prarms.put("age", "18");
String jsonPrarms = JSON.toJSONString(prarms);
CloseableHttpClient httpClient = HttpClientBuilder.create().build(); //获取浏览器信息
HttpPost httpPost = new HttpPost(url);
String encoding = DatatypeConverter.printBase64Binary("username:password".getBytes("UTF-8")); //username password 自行修改 中间":"不可少
httpPost.setHeader("Authorization", "Basic " + encoding);
HttpEntity entityParam = new StringEntity(jsonPrarms,ContentT