Created
January 29, 2014 17:34
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
everything with {{reference}} is a placeholder and should be replaced with the correct value.