By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,365 Members | 3,180 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,365 IT Pros & Developers. It's quick & easy.

Uploading a File on a shared documents folder programatically

P: n/a
All

I'm having trouble getting the following to work. I have been able to
download and delete a file with the same credentials and similar code,
but when I try upload the file. I get a returned error of "The Remote
server returned an error: (500) Internal Server Error." from the SPS.

Is there something that must be set up on SPS to allow a "PUT" or am I
missing something.
I am using very similar code to delete and download a file from the
same folder on the SPS. And its all working perfectly

Uri MSURI = new
Uri("https://DomainName.co.uk/Shared%20Documents/test/Test.txt");
NetworkCredential MSCred= new
NetworkCredential(MSUserID,MSPassword,MSDomain);
HttpWebRequest MSHttpWebRequest
=(HttpWebRequest)WebRequest.Create(MSURI);

CredentialCache MSCredentialCache = new CredentialCache();

MSCredentialCache.Add(MSURI, "Negotiate", MSCred);
MSHttpWebRequest.Credentials = MSCredentialCache;
MSHttpWebRequest.Method = "PUT";
MSHttpWebRequest.ContentType =
"text/plain";//"application/x-zip-compressed";
MSHttpWebRequest.Headers.Add("Translate", "f");
MSHttpWebRequest.Timeout = 30000;
MSHttpWebRequest.KeepAlive = false;

FileStream ostream;
byte[] obuffer;
ostream = File.OpenRead(AppConfig.XMLFeedFilePath + ZIPFile.Name);
obuffer = new byte[ostream.Length]; // byte buffer
ostream.Read(obuffer,0,obuffer.Length);
Stream srWriter=null;
srWriter = MSHttpWebRequest.GetRequestStream();
srWriter.Write(obuffer,0,obuffer.Length);
srWriter.Close();
ostream.Close();
HttpWebResponse MSResponse =
(HttpWebResponse)MSHttpWebRequest.GetResponse();
MSResponse.Close();

Has anyone else experienced similar behaviour and if so how were you
able to solve it.

Aug 31 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.