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.