public int CreateTicket(Ticket ticket) { var request = new ZenRestRequest { Method = Method.POST, Resource = Tickets + ".xml" }; request.AddBody(ticket); var res = Execute(request); return GetIdFromLocationHeader(res); }
public int CreateTicketAsEndUser(string endUserEmail, Ticket ticket) { var request = new ZenRestRequest { Method = Method.POST, Resource = Requests + ".xml" }; request.AddHeader(XOnBehalfOfEmail, endUserEmail); request.AddBody(ticket); //request.AddParameter("text/xml", string.Format("<ticket><subject>{0}</subject><description>{1}</description></ticket>", ticket.Subject, ticket.Description), ParameterType.RequestBody); var res = Execute(request); return GetIdFromLocationHeader(res); }
/// <summary> /// Sends the events. /// </summary> /// <param name="events">The events that need to be send.</param> /// <remarks> /// <para> /// The subclass must override this method to process the buffered events. /// </para> /// </remarks> protected override void SendBuffer(LoggingEvent[] events) { ZenDesk client = new ZenDesk(Url, User, Password); Parallel.ForEach(events, loggingEvent => { StringWriter writer = new StringWriter(); Layout.Format(writer,loggingEvent); Ticket ticket = new Ticket { Description = writer.ToString(), Subject = string.Format("{0} {1} {2} {3}", loggingEvent.TimeStamp, loggingEvent.ThreadName, loggingEvent.Level, loggingEvent.LoggerName), SetTags = Tags, RequesterId = RequesterId }; client.CreateTicket(ticket); }); }
/// <summary> /// To update custom ticket fields just add them to the ticket's TicketFieldEntries. /// Use GetTicketFields and then manually search to find the one you want to update. /// Note you can't add comments this way. Call AddComments to do that. /// </summary> /// <param name="ticket"></param> /// <returns></returns> public bool UpdateTicket(Ticket ticket) { ticket.Comments.Clear(); var request = new ZenRestRequest { Method = Method.PUT, Resource = string.Format("{0}/{1}.xml", Tickets, ticket.NiceId.ToString()) }; request.AddBody(ticket); var res = Execute(request); return res.StatusCode == System.Net.HttpStatusCode.OK; }