Hi Everyone,
As infopathdev users have been so kind in sharing their thoughts/solutions in the questions I have for Infopath, I would like to share the solution I've found for one of my problems.
Question found here: http://www.infopathdev.com/forums/p/7800/28534.aspx#28534
Solution:
Details: (Coding-VB Script), Add or update infopath forms/documents in a sharepoint document list.
Assumptions: Users running this code must have create/edit access to the sharepoint site.
sSubmitUrl = contains the full url of the infopath document you want to either add or update
XMLBody = this is the string that contains the complete infopath forms/documents contents, including PI's (Processing Instructions)
Code:
Imports System.Net
Imports System.IO
Dim sUrl As String = sSubmitUrl
Dim wResponse As WebRequest = WebRequest.Create(sUrl)
wResponse.Credentials = CredentialCache.DefaultCredentials
wResponse.Method = "PUT"
wResponse.Headers.Add("Translate: f")
wResponse.ContentLength = XMLBody.Length
wResponse.ContentType = "text/xml; charset=utf-8"
'write xml to the request stream.
Dim sw As New StreamWriter(wResponse.GetRequestStream())
sw.Write(XMLBody)
sw.Flush()
sw.Close()
Try
Dim resp As WebResponse = wResponse.GetResponse()
Catch ex As Exception
Exit Function
End Try