Read raw data stream using REST API from non-Sharepoint Server - InfoPath Dev
in

InfoPath Dev

Read raw data stream using REST API from non-Sharepoint Server

Last post 11-21-2015 05:52 PM by jeffh. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 11-21-2015 05:52 PM

    • jeffh
    • Not Ranked
    • Joined on 11-21-2015
    • Posts 1

    Read raw data stream using REST API from non-Sharepoint Server

    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" }, ] }
    Filed under:
Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.