0

Assume, that I wish to use an API from abc.com website.In the api documentation it says,

HTTP/1.x 200 OK GET /api/now/news Host: abc.com Api-Key:xxxxxxxxxx

to get news. How to write the codes to get a successful response in VB.net

Thank you.

DerStarkeBaer
  • 669
  • 8
  • 28

1 Answers1

0

Take https://www.google.com/ for an example, get the source code of the web page in UTF-8 format.

Imports System.Net
Imports System.Text

Public Class Form1

    Public Function Getwebcode(ByVal url As String, ByVal encoder As String) As String
        Dim myWebClient As WebClient = New WebClient()
        Dim myDataBuffer As Byte() = myWebClient.DownloadData(url)
        Dim SourceCode As String = Encoding.GetEncoding(encoder).GetString(myDataBuffer)
        Return SourceCode
    End Function

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim back As String = Getwebcode("https://www.google.com/", "UTF-8")
        TextBox1.Text = back
    End Sub
End Class
Julie Xu-MSFT
  • 334
  • 1
  • 5