Hello,
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.
data.put("code", array); data.put("langid",languageId); data.put("contest", contest_id); data.put("shortname",nombreProblema);
This is the code complete from my method:
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.
You should explain more detail about your use cases. About your source code, I think HttpURLConnection is more suitable. You can follow with some tutorials like this: https://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/
On Sat, Aug 6, 2016 at 10:07 PM Jesús Alberto Domínguez Alfonso < jesusalbertodominguez1983@gmail.com> wrote:
Hello,
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.
data.put("code", array); data.put("langid",languageId); data.put("contest", contest_id); data.put("shortname",nombreProblema);
This is the code complete from my method:
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. _______________________________________________ DOMjudge-devel mailing list DOMjudge-devel@domjudge.org https://www.domjudge.org/mailman/listinfo/domjudge-devel