I'm trying to get a JSON string via CURL:
curl https://{subdomain}.zendesk.com/api/v2/ticket_fields/{id}.json \
-v -u {email_address}:{password}
I can't get my head around how to convert this into a C# command, but I have been trying to use the WebClient and WebRequst class, but without any luck.
First i tried to access the URL via the WebClient:
var tags = api.Tickets.GetTicketFieldById(123456789);
WebClient client = new WebClient();
client.Credentials = new NetworkCredential("[email protected]", "abc123", "https://domain.zendesk.com/api/v2");
string json = client.DownloadString(tags.TicketField.Url);
But it throws an exception of 401 un-authorized.
I tried the same approach with the WebRequest/WebResponse, but same error came. I saw Zendesk was providing a CURL string to access the data, but I'm not sure on how to convert the CURL string into a C# command.
Can anybody help me access the returning JSON string?
Thanks in advance, Jesper.