From 7f4d25fa1e8cfa26a4e2cf3c293fae98721749dc Mon Sep 17 00:00:00 2001 From: Jasbeer Singh Date: Tue, 28 Jun 2016 18:32:25 +0530 Subject: [PATCH] Create ViewConversation To See all conversation of a ticket. Responses by Support team as well as replies by the client can be fetched by this. In this API Path : "/api/v2/tickets/" + id + "?include=conversations,requester"; requester is included (as embedded) to get the details of the requester also if you want to show the names who replied it will be beneficial. This is a static webmethod which is called using Ajax hit. you can modify it according to your need. --- C-Sharp/ViewConversation | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 C-Sharp/ViewConversation diff --git a/C-Sharp/ViewConversation b/C-Sharp/ViewConversation new file mode 100644 index 0000000..5a4e849 --- /dev/null +++ b/C-Sharp/ViewConversation @@ -0,0 +1,63 @@ +using Freshdesk; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Web; +using System.Web.Hosting; +using System.Web.Script.Serialization; +using System.Web.Services; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace Consume_FreshDesk_API +{ + public partial class ManageTicket : System.Web.UI.Page + { + + public static string ViewResponseTicket(int id) + { + string fdDomain = "domain"; // your freshdesk domain + string apiKey = "youkey"; // your freshdesk api Key + + string apiPath = "/api/v2/tickets/" + id + "?include=conversations,requester"; + + string responseBody = String.Empty; + HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://" + fdDomain + ".freshdesk.com" + apiPath); + request.ContentType = "application/json"; + request.Method = "GET"; + string authInfo = apiKey + ":X"; // It could be your username:password also. + authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo)); + request.Headers["Authorization"] = "Basic " + authInfo; + try + { + using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) + { + Stream dataStream = response.GetResponseStream(); + StreamReader reader = new StreamReader(dataStream); + responseBody = reader.ReadToEnd(); + reader.Close(); + dataStream.Close(); + } + + return responseBody.ToString(); + + } + catch (WebException ex) + { + + return ex.Message; + } + catch (Exception ex) + { + return ex.Message; + } + + } +} +}