zendesk / zendesk_api_client_php

Official Zendesk API v2 client library for PHP
336 stars 259 forks source link

Add comment to ticket #495

Closed gulios closed 2 years ago

gulios commented 2 years ago

Can't find method "add comment" to existing ticket.

// getting all comments for ticket $client->tickets(ID)->comments()->findAll();

Now i want to add comment with attachments to specific ticket. Same thing as agent can do via panel or cx replaying to specific email/ticket.

Is it possible ? How?

Thank you

RauchenwaldC commented 2 years ago

You have to use the Ticket endpoint for that.

$updateTicket = $client->tickets()->update( $ticketId, [ 'comment' => [ 'body' => 'My comment', ], ... ] );

However, that will create the comment as if your admin user (the user you generated the API token with) would have left it.
To create a new comment on behalf of the user you'd need to send a custom header (X-On-Behalf-Of: user@somewhere.com) which, as far as I can tell right now, is not supported by this SDK.
RauchenwaldC commented 2 years ago

Nevermind, just discovered https://github.com/zendesk/zendesk_api_client_php/issues/458#issuecomment-709351409 that should help you as well.

gulios commented 2 years ago

great, it works ;) Thank you