Youtrack API file

I am developing a web interface for viewing issue from youtrack on my web-portal. Question. if I can get the file attached to the API? No link, the binnary file. Thank you

I do not want to give access my visitors to youtrack. Only ip web server has access to api youtrack. Thanks
5 comments
Comment actions Permalink
Hello Vitaliy,

Yes, with the command it's possible.

Thank you.
0
Comment actions Permalink
Hi, Andrey.

Thanks for the answer. But I want to download an attachment from youtrack and not upload it.
0
Comment actions Permalink
Hi Vitaliy,

Thank you for clarification.
Then did you try Get attachments method? This URL can be used on your issue form. Otherwise, please specify the case in more details.

Thank you.
0
Comment actions Permalink
Thank you. I'll read the documentation
0
Comment actions Permalink
Found a solution.

//in my php
    $file = htmlspecialchars($_GET['name']);
    $fileid = htmlspecialchars($_GET['id']);
        $issue = $youtrack->getAttachmentContent("http://xx.xx.xx.xx:8080/_persistent/$file?file=$fileid");
    $header = $issue["type"];
    $content = $issue["content"];
    
    header("Content-Type: $header");
    header("Content-disposition: filename='$file'");
    echo $content;

// functions in class

public function getAttachmentContent($url)
..........
$result = $this->request('GET', $url);
......
return array(
'content' => $result['content'],
'type' => $result['response']['content_type'],
);


protected function request($method, $url)
....
switch ($method) {
            case 'GET':
curl_setopt($this->http, CURLOPT_HTTPGET, true);
break;
            case 'PUT':
......
$content = curl_exec($this->http);
$response = curl_getinfo($this->http);
......
        return array(
            'content' => $content,
            'response' => $response,
        );
0

Please sign in to leave a comment.