Last active
April 4, 2018 18:38
-
-
Save jskeet/24fc234cc1e9d6c5106714d1b106849f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
string type = "test"; | |
string data = @"{""fields"":{""project"":{""key"": ""MD""},""summary"": | |
""Support EXAMPLE"",""description"": ""Testing Support"",""issuetype"": | |
{""name"": "+ type +" }}}"; | |
string postUrl = "https://aconline.atlassian.net/rest/api/2/issue"; | |
byte[] cred = UTF8Encoding.UTF8.GetBytes("username:password"); | |
HttpClient client = new HttpClient | |
{ | |
DefaultRequestHeaders = | |
{ | |
Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred)), | |
Accept = { new MediaTypeWithQualityHeaderValue("application/json") } | |
}, | |
BaseAddress = new Uri(postUrl) | |
}; | |
HttpContent content = new StringContent(data, Encoding.UTF8, "application/json"); | |
HttpResponseMessage response = client.PostAsync("issue", content).Result; | |
if (response.IsSuccessStatusCode) | |
{ | |
ViewData["Result"] = "Success! your issue has been posted."; | |
} | |
else | |
{ | |
ViewData["Result"] = response.Content.ReadAsStringAsync().Result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment