Confluence HTTP Request 403 Forbidden

Deleted user October 31, 2023

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

0 votes
Deleted user October 31, 2023

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
Product Admin
TAGS
AUG Leaders

Atlassian Community Events