From 0afc634d5b26f979653f35f442c1cc40361d2796 Mon Sep 17 00:00:00 2001 From: Bernard Labno Date: Tue, 30 Oct 2012 10:07:05 +0000 Subject: [PATCH] No line breaks in description while creating new ticket. --- src/main/java/pl/com/it_crowd/youtrack/api/YoutrackAPI.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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); -- libgit2 0.24.0