我有以下卷曲要求:使用的HttpClient使HTTPGET请求
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
我失去的是什么?任何帮助将不胜感激!