【发布时间】:2017-04-23 16:19:49
【问题描述】:
我有以下 cURL 请求:
curl -H "AuthToken: anything" http://localhost:9999/my_service/data?%24expand=total%2Callocated
我想使用 Apache HttpClient 在我的应用程序中进行此调用。我的代码如下:
HttpGet httpGet = new HttpGet(uri);
httpGet.setConfig(myConfig);
httpGet.addHeader("-H", "AuthToken: anything");
response = this.httpClient.execute(httpGet, httpClientContext);
但是,这不起作用 - 我得到一个响应代码 400。
我在这里缺少什么?任何帮助将不胜感激!
【问题讨论】:
标签: java curl apache-httpclient-4.x http-get