zendesk_api_client_rb icon indicating copy to clipboard operation
zendesk_api_client_rb copied to clipboard

Prevent race conditions when finding tickets and adding new comments

Open BallerChan opened this issue 7 years ago • 0 comments

I am struggling to figure out how to grab the server response and make changes to the ticket after do a search. This is a common occurrence that is raising issues on my rails app.

client = Zendesk.client ticket = client.tickets.find(:id => TICKET_ID) ticket.comment = ZendeskAPI::Ticket::Comment.new(client, :body => BODY)

Due to me being unable to grab the response (200 or 304), I am unable to check if the ticket has been found or if there's an error leading to this lovely error:

undefined method 'comment=' for nil:NilClass when I try to add a new comment to the ticket.

Is there a way to grab the status code of the API request and wait until I receive a response from the server to proceed?

BallerChan avatar May 13 '18 22:05 BallerChan