I have been trying to use the sharepoint web service (from webs.asmx) GetWebCollection to get a list of the sites available to a user. I have authenticated successfully with with sharepoint and if I hard code in the site path I can get files back. However, when I try and use GetWebCollection I am given a “403 Forbidden” error?
What is required to be down differently?
Alternatively, is there any way to tell what site the user is automatically assigned to?
I am connecting via SOAP (with ASIHTTPRequest) in Objective-C.
- (void)getUrl {
NSURL *url = [NSURL URLWithString:@"https://[server]/_vti_bin/Webs.asmx"];
requestGetSites = [ASIHTTPRequest requestWithURL:url];
[requestGetSites setDelegate:self];
NSString *soapMessage = @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n"
"<GetWebCollection xmlns=\"http://schemas.microsoft.com/sharepoint/soap\" />\n"
"</soap:Body>\n"
"</soap:Envelope>";
[requestGetSites setUseCookiePersistence:NO];
[requestGetSites setUsername:@"username"];
[requestGetSites setPassword:@"password"];
[requestGetSites appendPostData:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[requestGetSites addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
[requestGetSites addRequestHeader:@"Host" value:@"[a server]"];
[requestGetSites addRequestHeader:@"SOAPAction" value:@"http://schemas.microsoft.com/sharepoint/soap/GetWebCollection"];
NSLog(@"Request headers are: %@", [[requestGetSites requestHeaders] description]);
[requestGetSites startSynchronous];
}
I have open-sourced a SharePoint library that I use to connect to SharePoint available at http://github.com/woodnathan/SPConnector