I want to send a POST Request to the Octoprint API via the Apache HttpClient, something like shown here: http://docs.octoprint.org/en/master/api/job.html#issue-a-job-command (e.g. to start a job). I've read the docs of both, but still getting "Bad Request" as answer.
Tried several other Post Request, but never getting something else. Guess I'm writing the request wrong somehow.
CloseableHttpClient posterClient = HttpClients.createDefault();
HttpPost post = new HttpPost("http://localhost:5000/api/job");
post.setHeader("Host", "http://localhost:5000");
post.setHeader("Content-type", "application/json");
post.setHeader("X-Api-Key", "020368233D624EEE8029991AE80A729B");
List<NameValuePair> content = new ArrayList<NameValuePair>();
content.add(new BasicNameValuePair("command", "start"));
post.setEntity(new UrlEncodedFormEntity(content));
CloseableHttpResponse answer = posterClient.execute(post);
System.out.println(answer.getStatusLine());