Confluence REST API Authorization issue

∥☆過路亽.° 提交于 2019-12-08 06:03:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!