有这样一个卷曲命令:
curl -k -X GET -H "Accept: Application/json" -H "Content-Type: application/json" -u XXX:YYY https://someUrl/customer/v1/85230000105
其中XXX是用户名,YYY是密码,85230000105是需要发送到Web服务的参数
我尝试编写这样的java代码:
HttpGet request = new HttpGet("https://someUrl/customer/v1/85230000105");
request.addHeader("content-type", "application/json");
request.addHeader("accept", "application/json");
request.addHeader("username", "XXX");
request.addHeader("password", "YYY");
这种转换是否正确?当我直接运行curl命令时,我可以获得回复成功,但是当我做
时httpResponse = httpClient.execute(request);
请帮我找到原因。