Add a reference in your application to Microsoft.Dynamics.GP.BusinessObjects which can be found in the Microsoft Dynamics\GP 2015 directory.
Function GetSite(strUserName As String, strPassword As String, strMachineName As String) As Microsoft.Dynamics.GP.BusinessObjects.Inventory.Site
'note that all the objects are fully qualified, to make the code more transportable
'initialize an object that will represent a Dynamics Site object
Dim oJSONSite As JSONSite = Nothing
Try
'passing in the machine name makes the examples easier to code and publish
Dim strUrl As String = String.Format("https://{0}/GPService/Tenants(DefaultTenant)/Companies(Fabrikam,%20Inc.)/Dynamics/Inventory/Sites(01-N)", strMachineName)
Dim oRequest As System.Net.HttpWebRequest
Dim oResponse As System.Net.WebResponse = Nothing
' Create the web request
oRequest = DirectCast(System.Net.WebRequest.Create(strUrl), System.Net.HttpWebRequest)
' Add authentication to request
oRequest.Credentials = New System.Net.NetworkCredential(strUserName, strPassword)
' Get the response
oResponse = DirectCast(oRequest.GetResponse(), System.Net.WebResponse)
'convert the response to a Stream
Dim oStream As System.IO.Stream = oResponse.GetResponseStream()
'convert the Stream to a StreamReader
Dim oStreamReader As New System.IO.StreamReader(oStream)
'read the response into a String
Dim strResponse As String = oStreamReader.ReadToEnd
'initialize a JavaScriptSerializer object
Dim js As New System.Web.Script.Serialization.JavaScriptSerializer()
'this is method #1, we'll read the Response into a Site object
'deserialize the response into the Site object
oJSONSite = js.Deserialize(Of JSONSite)(strResponse)
'this is an example of how the data is used
Dim strLocationCode As String = oJSONSite.Payload.LocationCode
'this is method #2, we'll read the response into a dictionary object
'this dictionary will have two nodes, Status and Payload
Dim dicResponse As Dictionary(Of String, Object) = js.Deserialize(Of Dictionary(Of String, Object))(strResponse)
'this dictionary takes the Payload out and makes it easier to access
Dim dicPayload As Dictionary(Of String, Object) = dicResponse("Payload")
Dim strLocationCode2 As String = dicPayload("LocationCode")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return oJSONSite.Payload
End Function