Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No icon / thumbnail for attached files when added via API #3309

Closed
apiening opened this issue Nov 28, 2020 · 0 comments
Closed

No icon / thumbnail for attached files when added via API #3309

apiening opened this issue Nov 28, 2020 · 0 comments
Assignees
Milestone

Comments

@apiening
Copy link

Infos:

  • Used Zammad version: 3.6.x
  • Installation method: Docker-Compose
  • Operating system: Docker (Mac OS X)
  • Browser + version: Firefox 83.0

Expected behavior:

When a file attachment is added to a ticket / article, it should be displayed with an icon for the given mime-type, or a thumbnail in case of an image file.

Actual behavior:

When a ticket / article has been created in the web interface or by incoming mail, the icon / thumbnail in front of the linked filename is shown correctly.
If the same entry gets created via API, an icon with a question mark (?) with a squared border is displayed instead of the actual thumbnail.

Steps to reproduce the behavior:

  • Save the following PHP-script to a file (named addarticle.php for example):
<?php

//url
$baseurl = 'http://localhost';
$url = $baseurl . '/api/v1/ticket_articles?expand=true';

//Credentials
$client_id  = "username";
$client_pass = "password";

//ID of the ticket where this article should be added
$ticket_id = 40;

$create_article_data = [
    "ticket_id" => $ticket_id,
    "subject" => "some subject",
    "body" => "<h2>test</h2>huhuhuu<br>huhuhuu<br>huhuhuu<br><br>",
    "content_type" => "text/html",
    "type" => "note",
    "internal" => false,
    "attachments" => [
        [
            "filename" => "simpleimage.png",
            "data" => base64_encode(file_get_contents("simpleimage.png")),
            "mime-type" => "image/png",
        ]
    ]
];

$content = json_encode($create_article_data);

//HTTP options
$opts = array('http' =>
array(
    'method'    => 'POST',
    'header'    => array('Content-type: application/json', 'Authorization: Basic ' . base64_encode("$client_id:$client_pass")),
    'content' => $content
));

//Do request
$context = stream_context_create($opts);
$json = file_get_contents($url, false, $context);

$result = json_decode($json, true);
if (json_last_error() != JSON_ERROR_NONE) {
    return null;
}

print_r($result);
  • Update the variables on top of the script to match your dev environment, especially $baseurl, $client_id, $client_pass and ticket_id.
  • Run the script with php addarticle.php (or whatever your php file is named)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
OLD Workflow
  
Done
Development

No branches or pull requests

3 participants