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
12 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);
    }
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);
    }


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

I am sorry to resurrect this old issue, but I was not able to find the information I seek otherwise (and link to this issue came up quite high in my Google search).

I am looking for a way of formatting the issue description using the current Markdown support in YouTrack. AFAIK there are two flavours of markdown, one that was used at the time of writing the original post here, the other that is used now (and that is consistent with Common Mark). However, using REST API, I can still only use the old markup format. Is there a way to change this behaviour?

0
Comment actions Permalink

Hi!

I'm Sergey from the YouTrack team.

there are two flavours of markdown

There are Markdown and Wiki. This thread is about Wiki syntax. We deprecated Wiki syntax a couple of years ago. Yet, we continued to render Wiki for old content for a while, and it was available in the REST API. In the recent 2022.2 update, all the Wiki parts were removed from the codebase completely.

So please upgrade to the last build of 2022.2 version, and you will only have the Markdown option by default.

0
Comment actions Permalink

Many thanks Sergey for your quick answer.

0

Please sign in to leave a comment.