Add SharePoint List row by posting a Soap Envelope

Example showing how to do a POST to a SharePoint list from a .NET web application. The purpose of the POST is to add a new row in a specific SharePoint list. 

In this example the list has three columns;

  1. Title, Single line of text
  2. MeasuredValue, Number
  3. TimeStamp, Date and Time

Parameters to adjust in the code sample;

  • listGUID
  • listURI
  • NetWorkCredential, YourADUserName, YourADPassword and YourDomain

References;

Code sample:

    Sub AddListRow()

        Dim Title As String = "Snowing"

        Dim MeasuredValue As String = "-2.3"

        Dim TimeStamp As DateTime = DateTime.Now

        Dim listGUID As String = "{0600A25B-2FFC-43B0-8AF9-7E73AA9013DA}"

        Dim listURI As String = "http://YourSharePointUrl/_vti_bin/lists.asmx"

 

        Dim soapEnvelope As New StringBuilder

        With soapEnvelope

            .AppendLine("<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">")

            .AppendLine("<soap12:Body>")

            .AppendLine("<UpdateListItems xmlns=""http://schemas.microsoft.com/sharepoint/soap/"">")

            .AppendLine(String.Format("<listName>{0}</listName>", listGUID))

            .AppendLine("<updates>")

            .AppendLine("<Batch>")

            .AppendLine("<Method ID=""1"" Cmd=""New"">")

            .AppendLine(String.Format("<Field Name=""Title"">{0}</Field>", Title))

            .AppendLine(String.Format("<Field Name=""MeasuredValue"">{0}</Field>", MeasuredValue))

            .AppendLine(String.Format("<Field Name=""TimeStamp"">{0}</Field>", TimeStamp))

            .AppendLine("</Method>")

            .AppendLine("</Batch>")

            .AppendLine("</updates>")

            .AppendLine("</UpdateListItems>")

            .AppendLine("</soap12:Body>")

            .AppendLine("</soap12:Envelope>")

        End With

 

 

        Dim client As New WebClient()

        With client

            .Credentials = New NetworkCredential("YourADUserName", "YourADPassword", "YourDomain")

            .Headers("SOAPAction") = "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"

            .Headers("Content-Type") = "application/soap+xml; charset=utf-8"

            .Encoding = Encoding.UTF8

        End With

 

 

        Dim response As String = client.UploadString(New Uri(listURI, UriKind.Absolute), "POST", soapEnvelope.ToString)

 

        wcResult.Text = response

 

    End Sub

13 comments for “Add SharePoint List row by posting a Soap Envelope”

  1. Posted Friday, July 18, 2014 at 4:44:50 AM

    This is a really good read for me ,Thanks for posting this informative article.

  2. Posted Tuesday, October 14, 2014 at 12:24:14 PM

    Information was good,i like your post.
    Looking forward for more on this topic
    <a href="http://staygreenacademy.com/"> SharePoint Administration Training in Hyderabad</a>

  3. Posted Tuesday, October 14, 2014 at 12:36:01 PM

    Wooh this is very informative article. Thank you so much..!
    <a href="http://staygreenacademy.com/sharepoint-training-institutes-in-hyderabad-india/">SharePoint Developer Training in Hyderabad</a>

  4. Posted Tuesday, October 14, 2014 at 12:45:19 PM

    This article is very good.informative style.. brilliant piece of advice.
    <a href="http://khalil-kothia.com/">SharePoint Online Training in Hyderabad</a>

  5. Posted Tuesday, October 14, 2014 at 12:53:22 PM

    It is incredible and informative knowledge. Impressive.
    <a href="http://sharepointtraininginhyderabad.in/">SharePoint Training Institutes in Hyderabad</a>

  6. Posted Saturday, February 7, 2015 at 6:08:30 AM

    I absolutely love your blog and find nearly all of your post’s to be precisely what I’m looking for.
    <a href="http://www.hungrymind.in">Free Tutorial</a>, <a href="http://www.hungrymind.in">Free Interview Questions</a>, <a href="http://www.hungrymind.in">Online Training Websites</a>

  7. Posted Saturday, February 7, 2015 at 6:21:44 AM

    Information was good, I like your post.
    Looking forward for more on this topic.
    <a href="http://hungrymind.in/sharepoint-free-videos-for-online-training-and-tutorial/">SharePoint Online free videos and Tutorials</a>, <a href="http://hungrymind.in/sharepoint-free-videos-for-online-training-and-tutorial/">Sharepoint Online Training</a>

  8. Posted Saturday, February 7, 2015 at 6:32:42 AM

    Wonderful post however I was wondering if you could write a little more on this topic? I’d be very thankful if you could elaborate a little bit further. Thank you!
    <a href="http://staygreenacademy.com">SharePoint Training</a>

  9. Posted Saturday, February 7, 2015 at 6:33:26 AM

    Great article ...Thanks for your great information, the contents are quiet interesting. I will be waiting for your next post.
    <a href="http://khalil-kothia.com">SharePoint 2013 Trainings</a>

  10. Posted Friday, June 19, 2015 at 7:19:43 AM

    This information you provided in the blog that was really unique I love it!!, Thanks for sharing such a great blog..Keep posting..

  11. Posted Tuesday, May 10, 2016 at 8:42:33 AM

    interesting piece of information, I had come to know about your web-page from my friend pramod, jaipur,i have read atleast eight posts of yours by now, and let me tell you, your blog gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a million once again, Regards <a href="http:// www.traininghyderabad.in/2016/02/guidewire-training-in-hyderabad.html">Guidewire training in hyderabad</a>

  12. Posted Wednesday, March 1, 2017 at 1:02:55 PM

    Once I initially commented I clicked the Notify me when new feedback are added checkbox and now each time a remark is added I get four emails with the same comment. Is there any way you possibly can remove me from that service? Thanks! edeadbddabkdbeaa

  13. Posted Tuesday, July 30, 2019 at 11:31:32 AM

    Appreciating the persistence you put into your blog and detailed information you provide.

Post a comment