Format description text (REST API)

Hi

I'm using the Rest API to create ticket issue.
I was wondering how can I do to format the desciption text accross the Rest API.

I just need the carriage return to structure the description otherwise it's unreadable (<br/>).
The system does not accept HTML.

Cheers

Alain
9 comments
Comment actions Permalink
Hi! You can use YouTrack Wiki markup, it is described here: http://confluence.jetbrains.net/display/YTD4/Quick+Start+Guide.+Using+Wiki+Markup
0
Comment actions Permalink
Thank you, it works.
Do you know if this list of Wiki markup is full ?
0
Comment actions Permalink
Yes, it's full, if you want to have new lines, you can just use regular new line character.
0
Comment actions Permalink
Huuum, how do you include a regular new line character from the REST API ?
Have tried "\n\r", I pretty sure you can't transfer carriage return or any  none alphanumeric character.
0
Comment actions Permalink
So \n\r didn't work for you? Could you please attach code example.
0
Comment actions Permalink
Maybe I miss something, how do you send the character 0xD and 0xA accross an HTTP resquest (\n\r)?
I can send only printable characters.
0
Comment actions Permalink
miss something, how do you send the character 0xD and 0xA accross an HTTP resquest (\n\r)?
I can send only printable charact


Same here. You can't sent newline in GET request. We could do it with POST most probably.
Besides I think that GET request limits the length of query string.
0
Comment actions Permalink
Here's my code using httpClient 4.2
    public String createIssue(String project, String summary, String description) throws IOException
    {
        final URI uri;
        try {
            uri = new URIBuilder(serviceLocation + "/rest/issue").addParameter("project", project)
 .addParameter("summary", summary)
 .addParameter("description", description)
 .build();
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
        final HttpResponse response = httpClient.execute(new HttpPut(uri));
        final StatusLine statusLine = response.getStatusLine();
        final HttpEntity entity = response.getEntity();
        final String responseText = entity == null ? null : EntityUtils.toString(entity);
        throwExceptionsIfNeeded(statusLine, responseText);

        final Header header = response.getFirstHeader(HttpHeaders.LOCATION);
        if (header == null) {
            throw new YoutrackAPIException("Missing location header despite positive status code: " + statusLine.getStatusCode());
        }
        final String issueURL = header.getValue();
        final Matcher matcher = Pattern.compile(".*(" + project + "-\\d+)").matcher(issueURL);
        if (!matcher.find() || matcher.groupCount() < 1) {
            throw new YoutrackAPIException("Cannot extract issue id from issue URL: " + issueURL);
        }
        return matcher.group(1);
    }
prettyPrint();
0
Comment actions Permalink
I've resolved this by using POST or PUT method:

    public String createIssue(String project, String summary, String description) throws IOException
    {
        final URI uri;
        try {
            uri = new URIBuilder(serviceLocation + "/rest/issue").build();
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
        final HttpPost request = createPostRequest(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);
        throwExceptionsIfNeeded(statusLine, responseText);

        final Header header = response.getFirstHeader(HttpHeaders.LOCATION);
        if (header == null) {
            throw new YoutrackAPIException("Missing location header despite positive status code: " + statusLine.getStatusCode());
        }
        final String issueURL = header.getValue();
        final Matcher matcher = Pattern.compile(".*(" + project + "-\\d+)").matcher(issueURL);
        if (!matcher.find() || matcher.groupCount() < 1) {
            throw new YoutrackAPIException("Cannot extract issue id from issue URL: " + issueURL);
        }
        return matcher.group(1);
    }
prettyPrint();

Notice that POST will return a bit different response then PUT.
0

Please sign in to leave a comment.