Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:57:06+00:00 2026-06-05T11:57:06+00:00

I am trying to upload file to sharepoint. Authorization works fine, but it ends

  • 0

I am trying to upload file to sharepoint. Authorization works fine, but it ends up with status OK instead of CREATED. Eventually the file is not created. I do not understand why it’s happening since I used approach that seems to work for others (no complaints). Here’s the code that I am using:

Public Sub Create()
    Dim szURL1 = "http://host.domain.com/p/projects/4/Proposal/cze.txt"

    Dim szContent = String.Format("Date/Time: {0} {1}", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString())

    'Define username and password strings.
    Dim domain = "DOMAIN_NAME"
    Dim szUsername = "USER_NAME"
    Dim szPassword = "PASSWORD"

    Dim httpPutRequest As HttpWebRequest = DirectCast(WebRequest.Create(szURL1), HttpWebRequest)
    httpPutRequest.Credentials = New NetworkCredential(szUsername, szPassword, domain)
    httpPutRequest.PreAuthenticate = True
    httpPutRequest.Method = "PUT"
    httpPutRequest.Headers.Add("Overwrite", "T")
    httpPutRequest.ContentLength = szContent.Length

    'Optional, but allows for larger files.
    httpPutRequest.SendChunked = True

    Dim requestStream = httpPutRequest.GetRequestStream()

    'Write the string to the destination as a text file.
    requestStream.Write(System.Text.Encoding.UTF8.GetBytes(DirectCast(szContent, String)), 0, szContent.Length)

    'Close the request stream.
    requestStream.Close()

    'Retrieve the response.
    Dim httpPutResponse As HttpWebResponse = DirectCast(httpPutRequest.GetResponse(), HttpWebResponse)
    Debug.WriteLine("PUT Response #1: {0}", httpPutResponse.StatusDescription)
End Sub

This produces: PUT Response #1: OK and not PUT Response #1: CREATED

I took the code from: http://blogs.iis.net/robert_mcmurray/archive/2010/02/09/sending-webdav-requests-in-net.aspx and translated it to VB, but I do not think that translation is the problem.

Any ideas?

EDIT:
I checked original C# code and the outcome is the same. What could be the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:57:08+00:00Added an answer on June 5, 2026 at 11:57 am

    I have no idea why the above does not work. I wrote this simple code and it works:

    var client = new WebClient();
    client.Credentials = new NetworkCredential(username, password, domain);
    client.UploadData("http://host.domain.com/p/projects/4/Proposal/cze.txt", "PUT", Encoding.UTF8.GetBytes(DateTime.Now.ToString()));
    

    If someone can answer the original question I will upvote it and accept it as an answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to upload file to an sharepoint online server using webclient. Up
I was trying to upload file(s) using PrototypeJs request method but I failed. The
I'm trying to upload a file .txt in my web space, but then the
I'm trying to upload a file to SharePoint programmatically via a Mac Application that
I am trying to upload file to FTP server using php but it is
I am trying to upload file to my youtube account but somehow I can't
trying to upload a file on a facelets page using Tomahawk2.0 1.1.11. But I
I'm trying to upload a file with Apache's HTTP Client and MultipartRequests, but it
I am trying to do a file upload from Silverlight(Client Object Model) to Sharepoint
I´m trying to upload a file which is fetched from a server. But when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.