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.