Hi,
I am facing two problems while accessing the Sharepoint server URL using HttpWebRequest/HttpWebResponse.
Sample Code:
try
{
string Url = "http://
Uri destUri = new Uri(Url);
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(destUri);
CredentialCache cache = new CredentialCache();
cache.Add(req.RequestUri, "Negotiate", new NetworkCredential(strUserName, strPassword, strDomain));
cache.Add(req.RequestUri, "NTLM", new NetworkCredential(strUserName, strPassword, strDomain));
req.Credentials = cache;
HttpWebResponse ores = (HttpWebResponse)req.GetResponse();
ores.Close();
if(ores.StatusDescription.ToLower() == "ok")
{
MessageBox.Show("Success");
}
else
{
MessageBox.Show(ores.StatusDescription);
}
}
catch (WebException we)
{
MessageBox.Show("Web Exception : " + we.Message);
}
catch (Exception ex)
{
MessageBox.Show("General Exception : " + ex.Message);
}
Issue #1:
I have created the folder inside a folder under sharepoint document library(ex: DocumentLibrary\Folder1\Folder2)
Using the above code I am testing the connection, it returns Success up to Folder1(ex: http://
I am trying the add the Folder2 in URL, It returns web exception UnAuthorized for the same credential.(eg: http://
Issue #2: If there is any space in document library name, it returns web exception "Bad URL"
(eg: http://
Can any one help how to fix these problems?
Thanks
Ram
Munir ShaikhPosted Sep 26, 2007, 6:29 AM
Regarding the second point i just have a suggestion actually space is represented in browser url as %20 so either use %20 instead of space in the directory name, this broser does automatically but here i think the encoding part browser is not doing.
Regards,
>>Munnamax