INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

PUT method authentication issue to SharePoint

PUT method authentication issue to SharePoint

(OP)
I have a web service that uses httpWebRequest PUT method to take a network file and place it in a SharePoint library.
When I run this service from my workstation it works perfect, but I receive an 401.2 authentication error when trying to run it from a production server. It grabs the network file ok but errors with calling GetResponse.
The web service is using the Network Service account.

I have spend hours trying to get this to work. Does anyone have any ideas on what the problem may be.

Thank you

Function UploadFileToSharePoint(ByVal UploadedFilePath As String, ByVal SharePointPath As String, ByVal LogFileName As String) As Boolean
        Dim b As Boolean = False
        Dim x As Int16 = 0

        Try

           
            Dim request As HttpWebRequest = WebRequest.Create(SharePointPath)
           
          
            request.Credentials = CredentialCache.DefaultCredentials

            request.Method = WebRequestMethods.Http.Put

           Using stream As Stream = request.GetRequestStream()
               
                Using fsWorkbook As FileStream = File.Open(UploadedFilePath, FileMode.Open, FileAccess.Read)
                   
                    Dim buffer() As Byte = New Byte(fsWorkbook.Length) {}

                    Dim i As Integer = fsWorkbook.Read(buffer, 0, buffer.Length)

                    Do While i > 0
                        stream.Write(buffer, 0, i)
                        i = fsWorkbook.Read(buffer, 0, buffer.Length)
                    Loop

                End Using
            End Using

           
            Dim response As HttpWebResponse = Nothing
           
'THIS IS THE LINE THAT ERRORS
            response = request.GetResponse()

           
            'verify the new file is in the sharepoint library
            b = FileNameExistsInSharePoint(SharePointPath, LogFileName)
           
            response.Close()

        Catch ex As WebException
                  End Try

        Return b

    End Function

RE: PUT method authentication issue to SharePoint

(OP)
Forgot to mention that the web service is using integrated authentication. Web config user identity = true.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close