SharePoint Server help

Sep 8 2007 7:28 AM

Hi,

I am facing two problems while accessing the Sharepoint server URL using HttpWebRequest/HttpWebResponse.

Sample Code:

try
{
   string Url = "http://<sharepoint server>/<site>/<docment library>;
   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://<server>/<site>/DocumentLibrary/Folder1)

I am trying the add the Folder2 in URL, It returns web exception UnAuthorized for the same credential.(eg: http://<server>/<site>/DocumentLibrary/Folder1/Folder2)

Issue #2: If there is any space in document library name, it returns web exception "Bad URL"
(eg: http://<server>/<site>/Shared Documents)

Can any one help how to fix these problems?

Thanks
Ram


Answers (1)