问题
I am having issues with Atlassian Confluence REST API authentication. Please take a look at following C# code :
private string USERNAME = "test";
private string PASSWORD = "test";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://xxx.atlassian.net/wiki/rest/api/content?os_authType=basic&spaceKey=DEV&Title=Development&expand=space,body.view,version,container");
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(USERNAME + ":" + PASSWORD)));
request.Method = "GET";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
But this always produces an error : {"The remote server returned an error: (401) Unauthorized."}.
I have tried the same code with in-house REST Services with Basic Authentication and it yields correct result. Please can someone point out what am I missing in this ? Thanks.
回答1:
For the benefit of anyone : I was using my email as username. I had to replace it with the username assigned by JIRA.
来源:https://stackoverflow.com/questions/29531312/confluence-rest-api-authorization-issue