Please help.
I want to submmit a exercise,i have used a program make for me but i don´t know if i am doing something bad, i put four parameters.
private void testConsumerPOST(String array[], String nombreProblema, String languageId, String contest_id) {
String servletURL = "
http://192.168.1.146/domjudge/api/submissions";
URL servlet = null;
try {
servlet = new URL(servletURL);
System.out.println("Sending request to " + servletURL);
HttpURLConnection servletConnection = (HttpURLConnection) servlet.openConnection();
servletConnection.setRequestMethod("POST");
servletConnection.setDoOutput(true);
servletConnection.setDoInput(true);
//send the keys to the server
OutputStreamWriter out = new OutputStreamWriter(servletConnection.getOutputStream());
ObjectMapper mapper = new ObjectMapper(); //Jackson Object mapper
Map<String, Object> data = new HashMap<String, Object>();
data.put("code", array);
data.put("langid",languageId);
data.put("contest", contest_id);
data.put("shortname",nombreProblema);
// data.put("teamid",teamId);
out.write(mapper.writeValueAsString(data));
//objOut.flush();
//objOut.close();
} catch (MalformedURLException ex) {
Logger.getLogger(PostSubmission.class.getName()).log(Level.SEVERE, null, ex);
} catch (ProtocolException ex) {
Logger.getLogger(PostSubmission.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(PostSubmission.class.getName()).log(Level.SEVERE, null, ex);
}
}
king regards.