Trouble uploading a file onto Sharepoint



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

.



Relevant Pages

  • Re: Windows authentication for web service client??
    ... > Dim Response As System.Net.HttpWebResponse ... > make my http WEBDAV request here ... ... CredentialCache.DefaultCredentials will return the credentials that ... I have try the same approach using implicity impersonation, ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: ASP.NET and paypal
    ... Was there a need to display any form of response from the request make ... Dim ReceiveStream As Stream ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET and paypal
    ... show to the user so there is a need to display the response. ... was used to send the request in the first place and therefore already ... Dim ReceiveStream As Stream ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Windows authentication for web service client??
    ... >> Dim Response As System.Net.HttpWebResponse ... >> make my http WEBDAV request here ... ... CredentialCache.DefaultCredentials will return the credentials that ... > I have try the same approach using implicity impersonation, ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Encrypting the response
    ... I'm confused what I need to do to encrypt the response. ... request with the client/sender certificate and I have encrypted the request ... I get back my DataSet if I don't add any response encryption code. ... Dim responseContext As SoapContext = ResponseSoapContext.Current ...
    (microsoft.public.dotnet.framework.webservices.enhancements)

Loading