I am new to Infopath and have some experience with writing Excel macros in vba. I have an infopath form that once it is filled out by users it needs to be sent ("submitted") to a non-sharepoint server using the REST API. The format of the REST data is proprietary and so I need to parse the return data from a REST "GET" command with my own logic. Basically I will issue a REST "GET" to query the system and locate a unique ID, that I will turn around and update with new content using a REST "POST". I have experimented a bit with the code below but it is returning the error "Data at the root level is invalid. Line 1, position 1.". But the bigger issue is that I think my approach is all wrong. I think I would be better off is I could issue the "GET" command and return the text as a stream that I could parse, rather than XML which I believe will always be a problem because of the data format. If someone could point me in the right direction I would appreciate it greatly.
Dim resolver As New XmlUrlResolver()
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials
' Point the resolver at the desired resource and resolve as a stream.
Dim baseUri As New Uri("http://xxx.xx.xxx.x:80/tip/rest/v1/model/")
Dim fulluri As Uri = resolver.ResolveUri(baseUri, "application?orderby=name&select=name&limit=60&pretty=true")
Dim s As Stream
s = CType(resolver.GetEntity(fulluri, Nothing, GetType(Stream)), Stream)
' Create the reader with the resolved stream and display the data.
Dim reader As XmlReader = XmlReader.Create(s)
While reader.Read()
Console.WriteLine(reader.ReadOuterXml())
End While
REST API Command and return data format:
This command returns a list of the first 60 applications in the database: http://xxx.xx.xxx.x:80/tip/rest/v1/model/application?orderby=name&select=name&limit=60&pretty=true
The return data format is:
{
"model" : [ {
"_id" : "1969D1FC-2CE2-411B-9534-7F6B71C60513",
"_type" : "Application",
"name" : "Office 2010 Suite"
}, {
"_id" : "1C206CED-F009-48C7-AC1B-72BD51D67E6B",
"_type" : "Application",
"name" : "Adobe Reader XI"
}, {
"_id" : "B18CCC04-1B5F-4C35-AA47-0802BBB2D949",
"_type" : "Application",
"name" : "Active Directory Request"
}, ]
}