Hi,
I am using Zendesk API from this repository: https://github.com/zendesk/zendesk_api_client_php
It's good so far. I can create ticket, find, update, upload attachment, etc. But when I want to get the ticket attachment, I can't find any method/function from the repo. I think it hasn't been implemented yet. The method clearly stated in https://developer.zendesk.com/rest_api/docs/support/attachments .
Show Attachment
GET /api/v2/attachments/{id}.json
Then I tried to implement it by adding a new function 'show' in Zendesk/API/Resources/Core/Attachments.php like this:
protected function setUpRoutes()
{
$this->setRoutes([
'upload' => "uploads.json",
'deleteUpload' => "uploads/{token}.json",
'show' => "attachments/{id}.json",
]);
}
public function show($id=null)
{
$response = Http::send(
$this->client,
$this->getRoute(__FUNCTION__, ['id' => $id]),
['method' => 'GET']
);
return $response;
}
Then I call the function from my php file like this:
...
$attachment = $client->attachments()->show($ticketId);
print_r($attachment);
But I get 404 response {"error":"RecordNotFound","description":"Not found"}. Actually there is an attachment file in the ticket.
How to do it correctly?