Trouble uploading a file onto Sharepoint
- From: Paul.Hawkes@xxxxxxxxx
- Date: 1 Sep 2006 11:34:24 -0700
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
I tried posting this on 2 other groups
(http://groups.google.com/group/microsoft.public.dotnet.languages.csharp)
and
http://groups.google.com/group/microsoft.public.sharepoint.portalserver.development
,but as yet have had no response, so I'm hoping someone could help me
out here
This code below is thanks to Ruslans on this thread
http://groups.google.com/group/microsoft.public.sharepoint.windowsservices/browse_frm/thread/581f0f0cda3b8950/f6f699fb4c194dd5?lnk=gst&q=ruslans&rnum=3#f6f699fb4c194dd5
Private Function CreateItem(ByVal strFolderURI As String, ByVal content
As String) As String
Dim Request As System.Net.HttpWebRequest
Dim Response As System.Net.HttpWebResponse
Try
' Create the HttpWebRequest object.
Request = CType(System.Net.WebRequest.Create(strFolderURI),
System.Net.HttpWebRequest)
' Add the network credentials to the request.
Dim SLBCred As NetworkCredential = New
NetworkCredential("Username", "Password")
Request.Credentials = SLBCred
' Specify the method.
Request.Method = "PUT"
Request.ContentType = "text/plain"
Request.ContentLength = content.Length
Request.Headers.Add("Translate", "f")
Dim myWriter As StreamWriter
Try
myWriter = New StreamWriter(Request.GetRequestStream())
myWriter.Write(content)
Catch e As Exception
Return e.Message
Finally
myWriter.Close()
End Try
' Send the MKCOL method request and get the response from
the server.
Response = Request.GetResponse()
' Clean up.
Response.Close()
Return "Item created at " + strFolderURI + "."
Catch ex As Exception
Return ex.Message
End Try
End Function
Many Thanks
Paul
.
- Follow-Ups:
- Re: Trouble uploading a file onto Sharepoint
- From: Engelbert
- Re: Trouble uploading a file onto Sharepoint
- Prev by Date: Re: MSNBC webpart issues - weather and news not updating
- Next by Date: Re: Alerts failing for some users
- Previous by thread: Re: MSNBC webpart issues - weather and news not updating
- Next by thread: Re: Trouble uploading a file onto Sharepoint
- Index(es):
Relevant Pages
|
Loading