You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I have a program that is extracting the Confluence left-pane hierarchical links from a Space XML export file. We need to build a SharePoint page that contains the hierarchical links. I'm getting a 403 in my c# program.
private static string GetHttpResponseCode(string pageId)
{
const string pageUrl = @"https://xxx.atlassian.net/wiki/spaces/ACE/pages/";
const string emailToken = "myemail@xxx.com:mytoken";
string encodedCreds = Base64Encode(emailToken);
string basicAuthValue = "Basic " + encodedCreds;
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(@"https://geicoit.atlassian.net/wiki/spaces/ACE/pages/" + pageId);
myReq.PreAuthenticate = true;
myReq.Headers.Add("Authorization", basicAuthValue);
myReq.Headers.Add("Accept", "application/json");
myReq.Headers.Add("Content-Type", "application/json");
string response;
response = myReq.GetResponse().ToString();
Console.WriteLine("\nThe HttpHeaders are \n\n\tName\t\tValue\n{0}", myReq.Headers);
return response;
}
}
Got it working:
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://xxx.atlassian.net/wiki/spaces/ACE/pages/37828657178");
request.Headers.Add("Authorization", "Basic token");
request.Headers.Add("Cookie", "JSESSIONID=xxx; atl.xsrf.token=xxx");
var response = client.Send(request);
response.EnsureSuccessStatusCode();
return response.StatusCode.ToString();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.