Skip to main content

C Sharp

GET

using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;

namespace WebApiRequest
{
class testATM
{
private static readonly HttpClient client = new HttpClient();

private static async Task AtmHttpRequest()
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Add("apiKey", "< YOURTOKEN >");

var bodyContent = new StringContent("{
\"options\": {
\"method\": \"GET\",
\"headers\": {
\"Content-Type\": \"application/json\",
\"Accept\": \"application/json\"
}
},
\"url\": \"/rest/api/3/issue/Dev-16\"
}", System.Text.Encoding.UTF8, "application/json");

var response = await client.PostAsync(new Uri("<YOUR ENDPOINT URL>"),bodyContent);

string responseString = await response.Content.ReadAsStringAsync();

Console.WriteLine(responseString);
}

static async Task Main (string[] arg){
await AtmHttpRequest();
}
}
}

POST

using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;

namespace WebApiRequest
{
class testATM
{
private static readonly HttpClient client = new HttpClient();

private static async Task AtmHttpRequest()
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Add("apiKey", "< YOURTOKEN >");

var bodyContent = new StringContent("{
\"options\": {
\"method\": \"POST\",
\"headers\": {
\"Content-Type\": \"application/json\",
\"Accept\": \"application/json\"
},
\"body\": {
\"fields\": {
\"project\":{
\"name\": \"<your project name>\"
},
\"summary\": \"Create Issue via POST.\",
\"description\": \"Creating of an issue via a POST request using the API Key Manager\",
\"issuetype\": {
\"id\": \"<your issue type id>\"
}
}
}
},
\"url\": \"/rest/api/2/issue\"
}", System.Text.Encoding.UTF8, "application/json");

var response = await client.PostAsync(new Uri("<YOUR ENDPOINT URL>"),bodyContent);

string responseString = await response.Content.ReadAsStringAsync();

Console.WriteLine(responseString);
}

static async Task Main (string[] arg){
await AtmHttpRequest();
}
}
}