Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1.             String uriStr = url + "pid=" + textfPID.getText() + "&issuetype=" + (cmbIssueType.getSelectedIndex() + 1) + "&summary=" + encode(textfSummary.getText()) + "&components=" + encode(textfComponent.getText()) + "&customfield_10050=" + encode(textfCustomer.getText()) + "&customfield_10011=" + encode(textfInstance.getText()) + "&customfield_10012=" + encode(textfContext.getText()) + "&priority=" + encode(textfPriority.getText()) + "&versions=" + encode(textfVersion.getText()) + "&description=" + encode(textaDesc.getText()) + "&customfield_10015=" + encode(textaError.getText()) + (loginUser ? "&os_username=" + encode(textfUsername.getText()) + "&os_password=" + encode(textfPassword.getText()) : "");
  2.  
  3.             URL url2 = new URL(url.substring(0,url.length()-1));
  4.             HttpURLConnection conn = (HttpURLConnection)url2.openConnection();
  5.             conn.setRequestMethod("POST");
  6.               conn.setAllowUserInteraction(false); // you may not ask the user
  7.             conn.setDoOutput(true); // we want to send things
  8.             conn.setDoInput(true);
  9.             // the Content-type should be default, but we set it anyway
  10.            // conn.setRequestProperty( "Content-type", "application/x-www-form-urlencoded" );
  11.             // the content-length should not be necessary, but we're cautious
  12.           //  conn.setRequestProperty( "Content-length", Integer.toString(uriStr.length()));
  13.             // get the output stream to POST our form data
  14.  
  15.             OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
  16.  
  17.             wr.write("pid=" + textfPID.getText() + "&issuetype=" + (cmbIssueType.getSelectedIndex() + 1) + "&summary=" + encode(textfSummary.getText()) + "&components=" + encode(textfComponent.getText()) + "&customfield_10050=" + encode(textfCustomer.getText()) + "&customfield_10011=" + encode(textfInstance.getText()) + "&customfield_10012=" + encode(textfContext.getText()) + "&priority=" + encode(textfPriority.getText()) + "&versions=" + encode(textfVersion.getText()) + "&description=" + encode(textaDesc.getText()) + "&customfield_10015=" + encode(textaError.getText()) + (loginUser ? "&os_username=" + encode(textfUsername.getText()) + "&os_password=" + encode(textfPassword.getText()) : "")); // here we "send" our body!
  18.             wr.flush();
  19.  
  20.              BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  21.             String line;
  22.                 while ((line = rd.readLine()) != null) {
  23.                 System.out.println(line);
  24.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement