diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java b/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java index 84caf60..208364a 100644 --- a/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java +++ b/src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java @@ -40,6 +40,7 @@ import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.security.KeyManagementException; @@ -183,14 +184,13 @@ public class YoutrackAPI { { final URI uri; try { - uri = new URIBuilder(serviceLocation + "/rest/issue").addParameter("project", project) - .addParameter("summary", summary) - .addParameter("description", description) - .build(); + uri = new URIBuilder(serviceLocation + "/rest/issue").build(); } catch (URISyntaxException e) { throw new RuntimeException(e); } - final HttpResponse response = httpClient.execute(new HttpPut(uri)); + final HttpPut request = createPutRequest(uri, new BasicNameValuePair("project", project), new BasicNameValuePair("summary", summary), + new BasicNameValuePair("description", description)); + final HttpResponse response = httpClient.execute(request); final StatusLine statusLine = response.getStatusLine(); final HttpEntity entity = response.getEntity(); final String responseText = entity == null ? null : EntityUtils.toString(entity); @@ -333,6 +333,13 @@ public class YoutrackAPI { } } + private HttpPut createPutRequest(URI uri, BasicNameValuePair... nameValuePair) throws UnsupportedEncodingException + { + final HttpPut request = new HttpPut(uri); + request.setEntity(new UrlEncodedFormEntity(Arrays.asList(nameValuePair))); + return request; + } + private String execute(HttpUriRequest request) throws IOException { final HttpResponse response = httpClient.execute(request);