drools-eclipse/org.kie.eclipse/src/main/java/org/kie/eclipse/server/KieServiceDelegate.java
protected String httpPost(String request, JsonObject body) throws IOException, RuntimeException {
		String host = getKieRESTUrl();
		URL url = new URL(host + "/" + request);
		Activator.println("[POST] "+url.toString()+" body: "+body);
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		conn.setDoOutput(body!=null);
		conn.setRequestMethod("POST");
		conn.setRequestProperty("Content-Type", "application/json");
		setHttpCredentials(conn);

		if (body!=null) {
			java.io.OutputStream os = conn.getOutputStream();
			Writer writer = new OutputStreamWriter(os, "UTF-8");
			body.writeTo(writer);
			writer.close();
			os.flush();
		}

		String response = new BufferedReader(new InputStreamReader((conn.getInputStream()))).readLine();
		Activator.println("[POST] response: "+response);

		if (conn.getResponseCode() != HttpURLConnection.HTTP_ACCEPTED) {
			throw new IOException("HTTP POST failed : HTTP error code : " + conn.getResponseCode());
		}

		JsonObject jo = JsonObject.readFrom(response);
		String status = jo.get("status").asString();
		if (status != null && !status.isEmpty()) {
			if (!"APPROVED".equals(status))
				throw new IOException("HTTP POST failed : Request status code : " + status);
		}
		String jobId = jo.get("jobId").asString();
		if (jobId != null && !jobId.isEmpty())
			return jobId;

		return response;
	}
protected String httpPost(String request, JsonObject body) throws IOException, RuntimeException {
		String host = getKieRESTUrl();
		URL url = new URL(host + "/" + request);
		Activator.println("[POST] "+url.toString()+" body: "+body);
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		conn.setDoOutput(body!=null);
		conn.setRequestMethod("POST");
		conn.setRequestProperty("Content-Type", "application/json");
		setHttpCredentials(conn);

		if (body!=null) {
			java.io.OutputStream os = conn.getOutputStream();
			Writer writer = new OutputStreamWriter(os, "UTF-8");
			body.writeTo(writer);
			writer.close();
			os.flush();
		}

		String response = new BufferedReader(new InputStreamReader((conn.getInputStream()))).readLine();
		Activator.println("[POST] response: "+response);

		if (conn.getResponseCode() != HttpURLConnection.HTTP_ACCEPTED) {
			throw new IOException("HTTP POST failed : HTTP error code : " + conn.getResponseCode());
		}

		JsonObject jo = JsonObject.readFrom(response);
		String status = jo.get("status").asString();
		if (status != null && !status.isEmpty()) {
			if (!"APPROVED".equals(status))
				throw new IOException("HTTP POST failed : Request status code : " + status);
		}
		String jobId = jo.get("jobId").asString();
		if (jobId != null && !jobId.isEmpty())
			return jobId;

		return response;
	}
protected String httpPost ( String request , JsonObject body ) throws IOException , RuntimeException { String host = getKieRESTUrl ( ) ; URL url = new URL ( host + "/" + request ) ; Activator . println ( "[POST] " + url . toString ( ) + " body: " + body ) ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setDoOutput ( body != null ) ; conn . setRequestMethod ( "POST" ) ; conn . setRequestProperty ( "Content-Type" , "application/json" ) ; setHttpCredentials ( conn ) ; if ( body != null ) { java . io . OutputStream os = conn . getOutputStream ( ) ; Writer writer = new OutputStreamWriter ( os , "UTF-8" ) ; body . writeTo ( writer ) ; writer . close ( ) ; os . flush ( ) ; } String response = new BufferedReader ( new InputStreamReader ( ( conn . getInputStream ( ) ) ) ) . readLine ( ) ; Activator . println ( "[POST] response: " + response ) ; if ( conn . getResponseCode ( ) != HttpURLConnection . HTTP_ACCEPTED ) { throw new IOException ( "HTTP POST failed : HTTP error code : " + conn . getResponseCode ( ) ) ; } JsonObject jo = JsonObject . readFrom ( response ) ; String status = jo . get ( "status" ) . asString ( ) ; if ( status != null && ! status . isEmpty ( ) ) { if ( ! "APPROVED" . equals ( status ) ) throw new IOException ( "HTTP POST failed : Request status code : " + status ) ; } String jobId = jo . get ( "jobId" ) . asString ( ) ; if ( jobId != null && ! jobId . isEmpty ( ) ) return jobId ; return response ; }
Send an HTTP POST request to the KIE console.

@param request - the request URL fragment; see the Drools REST API
documentation for details
@param body - the JSON object required by the request
@return the Job ID. This can be used in calls to getJobStatus() to fetch
the completion status of the request.
@throws IOException
@throws RuntimeException
Send an HTTP POST request to the KIE console .