Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Confluence HTTP Request 403 Forbidden

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;
}
}

1 answer

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();
}
}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events