我试图用一个小型的Java程序做了要求,但我得到一个400 - 错误的请求作为应答:获得400 - 错误的请求Java客户端
URI uri = new URIBuilder().setScheme("https")
.setHost("somehost.com")
.setPath("/API/v1/export").build();
HttpPost post = new HttpPost(uri);
post.setHeader("X-API-ID", "myId");
post.setHeader("Accept", "application/json");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("format", "csv"));
params.add(new BasicNameValuePair("userId", "userId"));
post.setEntity(new UrlEncodedFormEntity(params));
JsonNode responseJson = sendResponseEngineRequest(post);
这responseJson返回以下值:
{ “元”:{ “则httpStatus”: “400 - 错误 请求”, “错误”:{ “的errorMessage”:“无效的Content-Type 预期=应用程序/ JSON 发现= application/x-www-form-urlencoded“,”errorCode“:”RP_0.1“}}}
在此先感谢。
你能告诉我,我怎么可以要求“应用/ JSON”和以及我如何申请“应用程序/ x-WWW的形式,进行了urlencoded”那不是清楚为了我。 –
你有控制你要求数据的主机吗? – blur0224
嗯,不是真的,是提供者的主机。 –