I have tried to Make a POST request to below end point with the following JSON payload using vb.net webforms but the Imports System.Net.Http namespace is not recognised in visual studio, and how do I pass values from textbox to shared function string value (like the phone number as well as the message).

I have tried the following code to send sms

Private Shared Async Function Main() As Task
    Await SendJsonPayloadAsync()
End Function

Private Shared Async Function SendJsonPayloadAsync() As Task
    Dim apiUrl As String = "api_url"
    Dim jsonPayload As String = "{
        ""api_token"": ""3PDDDW...."",
        ""service_id"": 8731,
        ""sender_id"": ""TOS"",
        ""recipient"": [""255....""],
        ""message"": ""Hello World""
    }"

    Using client As HttpClient = New HttpClient()
        client.DefaultRequestHeaders.Add("Accept", "application/json")
        Dim content As StringContent = New StringContent(jsonPayload, Encoding.UTF8, "application/json")
        Dim response As HttpResponseMessage = Await client.PostAsync(apiUrl, content)
        If response.IsSuccessStatusCode Then
            Console.WriteLine("Request successfully sent!")
        Else
            Console.WriteLine($"Error: {response.StatusCode} - {response.ReasonPhrase}")
        End If
    End Using
End Function

New contributor

Choum Ahmed Khalifa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.