I tried with the following example but it does not work
public static void main(String[] args) { String data = "{\"fields\":{\"customfield_10005\":\"test\"}}"; this.authenticate(); URL url = new URL("http://jira.sylob.local/rest/api/2/issue/105868? fields=customfield_10005"); HttpURLConnection connection = this.httpGet(url.toString(), this.authCookie); OutputStreamWriter osw = new OutputStreamWriter(connection.getOutputStream()); osw.write(data); osw.flush(); } private void authenticate() throws Exception { StringBuilder authUrl = new StringBuilder("http://").append("jira.sylob.local").append("/rest/auth/1") .append("/session").append("?os_username=") .append(URLEncoder.encode("support", GeneralStatic.UTF8)).append("&os_password=") .append(URLEncoder.encode("support81", GeneralStatic.UTF8)); HttpURLConnection connection = (HttpURLConnection) new URL(authUrl.toString()).openConnection(); String cookie = ""; mainLoop: for (Entry<String, List<String>> headers : connection.getHeaderFields() .entrySet()) { if (StringUtils.equals(headers.getKey(), "Set-Cookie")) { for (String cookieTmp : headers.getValue()) { if (StringUtils.containsIgnoreCase(cookieTmp, "JSESSION")) { cookie = cookieTmp; break mainLoop; } } } } if (StringUtils.isEmpty(cookie)) { throw new StandardCochiseMetierException(new CochiseMessage( "importTempsJIRA.exception.authentification")); } this.authCookie = cookie; } private static HttpURLConnection httpGet(String url, String cookie) throws Exception { HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Accept", "application/json"); connection.setRequestMethod("PUT"); connection.setDoInput(true); connection.setDoOutput(true); if (StringUtils.isNotEmpty(cookie)) { connection.setRequestProperty("Cookie", cookie); } connection.connect(); return connection; }
Please Can you help me
Community moderators have prevented the ability to post new answers.
Whan namely does not work? Do you get any mistake or responce for this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.