Ich versuche, eine Anfrage mit einem kleinen Java-Programm zu tun, aber ich bin immer einen 400 - Bad Request als Antwort:Erste 400 - Bad Request-Java-Client
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);
Diese responseJson die liefert folgende Wert:
{ "meta": { "httpstatus":. "400 - Bad Request", "Fehler": { "errormessage": "Invalid Content-Type erwartet = application/json gefunden = application/x-www-form-urlencoded "," errorCode ":" RP_0.1 "}}}
Vielen Dank im Voraus.
Könnten Sie mir bitte sagen, wie ich „application/json“ anfordern können und auch, wie ich „application/x-www-form-urlencoded“ das ist, bin anfordernden nicht klar für mich. –
Haben Sie die Kontrolle über den Host, von dem Sie Daten anfordern? – blur0224
Naja, nicht wirklich, ist ein Host von einem Provider. –