Skip to content

Instantly share code, notes, and snippets.

@dpawluk
Created January 29, 2014 17:34
Show Gist options
  • Save dpawluk/8692890 to your computer and use it in GitHub Desktop.
Save dpawluk/8692890 to your computer and use it in GitHub Desktop.
Simple C# script using native HTTP Request handler (HttpWebRequest) to access /api/v2/tickets/{{ticket.id}}.json enpoint.
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Collections.Specialized;
namespace test2
{
class MainClass
{
public static void Main (string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://{{subdomain}}.zendesk.com/api/v2/tickets/{{###}}.json");
request.Credentials = new NetworkCredential("{{email_address}}/token", "{{APITOKEN}}");
request.Method = WebRequestMethods.Http.Get;
request.AllowAutoRedirect = true;
request.Proxy = null;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader streamreader = new StreamReader(stream);
string s = streamreader.ReadToEnd();
Console.Write (s);
}
}
}
@dpawluk
Copy link
Author

dpawluk commented Jan 29, 2014

everything with {{reference}} is a placeholder and should be replaced with the correct value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment