Hi,
I have try to add new componet to particula project using the below c# console application,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Json;
using System.Runtime.Serialization;
using System.Web.Script.Serialization;
using Newtonsoft.Json;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string data = @{"name"":""xxxxxx"",""project"":""yyyyyyyy""}";
string output;
HttpClientHandler newClientHandler = new HttpClientHandler();
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
client.DefaultRequestHeaders.ExpectContinue = false;
client.Timeout = TimeSpan.FromMinutes(90);
byte[] crdential = UTF8Encoding.UTF8.GetBytes("adminName:adminPassword");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(crdential));
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
System.Net.Http.HttpContent content = new StringContent(data, Encoding.UTF8, "application/json");
try
{
client.PostAsync("https://xxxYYYY.atlassian.net/rest/api/2/component", content).ContinueWith(requesTask =>
{
var response = requesTask.Result;
response.EnsureSuccessStatusCode();
response.Content.ReadAsStringAsync().ContinueWith(readTask =>
{
var out1 = readTask.Result;
Console.WriteLine("Response Result :" + out1);
});
});
Console.Read();
}
catch (Exception exc)
{
Console.WriteLine(exc.StackTrace.ToString());
Console.ReadLine();
}
}
}
}
when i run the application response status is below,
Response status code does not indicate success: 403 (Forbidden).
but i replace the uri like http://localhost:8080/rest/api/2/component it add the comoponent to the particular project.
How to solve this issue?