i have this json array response:
[
{
"status": "active",
"url": "https:\/\/ikiosk.podio.com\/dev\/apps\/myusers",
"url_label": "myusers",
"space_id": 550628,
"link_add": "https:\/\/ikiosk.podio.com\/dev\/apps\/2304568\/items\/new",
"app_id": 2304568,
"date_field": false,
"link": "https:\/\/ikiosk.podio.com\/dev\/apps\/myusers",
"config": {
"allow_edit": true,
"description": "",
"item_name": "myusers",
"type": "standard",
"icon_id": 251,
"allow_create": true,
"usage": "",
"icon": "251.png",
"external_id": null,
"name": "myusers"
},
"url_add": "https:\/\/ikiosk.podio.com\/dev\/apps\/2304568\/items\/new"
},
{
"status": "active",
"url": "https:\/\/ikiosk.podio.com\/dev\/apps\/requests",
"url_label": "requests",
"space_id": 550628,
"link_add": "https:\/\/ikiosk.podio.com\/dev\/apps\/2299738\/items\/new",
"app_id": 2299738,
"date_field": true,
"link": "https:\/\/ikiosk.podio.com\/dev\/apps\/requests",
"config": {
"allow_edit": true,
"description": "",
"item_name": "request",
"type": "standard",
"icon_id": 251,
"allow_create": true,
"usage": "",
"icon": "251.png",
"external_id": null,
"name": "Requests"
},
"url_add": "https:\/\/ikiosk.podio.com\/dev\/apps\/2299738\/items\/new"
}
]
And here the classes:
Public Class GetAllApps
Public pApplication As PodioApplication
End Class
Public Class PodioApplication
Public status As String
End Class
My code here:
Dim client As New RestClient()
client.BaseUrl = "https://api.podio.com/"
Dim request As New RestRequest()
request.RequestFormat = DataFormat.Json
request = New RestRequest()
request.Method = Method.[GET]
request.RequestFormat = DataFormat.Json
request.AddParameter("oauth_token", access_token)
request.Resource = "/app/v2//"
Dim resp = client.Execute(Of List(Of GetAllApps))(request)
RichTextBox1.Text = resp.Content
Dim pApps As List(Of PodioApplication) = resp.Data.[Select](Function(c) c.pApplication).ToList()
MsgBox(pApps.Count)
For Each p As PodioApplication In pApps
MsgBox(p.status)
Next
the json array that i wrote before is the result of resp.Content.
At line of code MsgBox(pApps.Count) I take the correct number (in this scenario is 2).
But in the for each loop I take the exception error: “Object reference not set to an instance of an object.”
Is there any problem with my implementation, something missing?
Finally,
I made it simple:
Now the pApps have the correct data from the response.