Pages

Saturday, 17 June 2023

Read (Consume) Rest API using VB.NET Windows Programming

 This post will help you to read a single record from API in JSON format using VB.Net Windows form Application.

Data formate 

{"roll":101,"name":"ram","city":"vns"}
Package Install
NuGet\Install-Package Newtonsoft.Json -Version 13.0.3
Code
Imports System.Net
Imports Newtonsoft.Json.Linq
  Dim json As String = New System.Net.WebClient().DownloadString("your api url")
  Dim parsejson As JObject = JObject.Parse(json)
  Label1.Text = "Roll=" & parsejson.SelectToken("roll").ToString  & ", Name=" &        parsejson.SelectToken("name").ToString  & ", City=" &   parsejson.SelectToken("city").ToString        

   Next Example

No comments:

Post a Comment