Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am new here and I am trying to learn how to use api. I found CMS data set which has a api. please see link below:

https://data.cms.gov/provider-data/dataset/avax-cv19

Question:
how can I use this api to display in gridview?
I dont want to use MVC to keep it simple.

What I have tried:

VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            
            TitleL.Text = GetAccountInfoFromApi("test")

        End If

    End Sub





    Private Function GetAccountInfoFromApi(accountno As String) As String
        Dim accountInformationUrl As String = "​/provider-data​/api​/1​/metastore​/schemas​/dataset​/items​/avax-cv19"
        Dim webClient As Net.WebClient = New WebClient()
        'Return webClient.DownloadString(New Uri(accountInformationUrl))
        Dim retString As String

        Try
            retString = webClient.DownloadString(New Uri(accountInformationUrl))

        Catch ex As WebException
            If ex.Status = WebExceptionStatus.ProtocolError AndAlso ex.Response IsNot Nothing Then
                Dim resp = DirectCast(ex.Response, HttpWebResponse)
                If resp.StatusCode = HttpStatusCode.NotFound Then
                    ' HTTP 404
                    'other steps you want here
                End If
            End If
            'throw any other exception - this should not occur
            Throw
        End Try
        Return retString

    End Function
Posted
Updated 21-Nov-22 4:26am

1 solution

 
Share this answer
 
Comments
Richard MacCutchan 21-Nov-22 10:35am    
You need to go and study the documentation. This is not something that we can do for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900