You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
964 B
31 lines
964 B
Imports System
|
|
Imports System.Collections.Generic
|
|
Imports System.Linq
|
|
Imports System.Text
|
|
Imports System.Threading.Tasks
|
|
Imports System.Net.Http
|
|
Imports System.Net.Http.Headers
|
|
|
|
Namespace HttpClientDemo
|
|
Class Program
|
|
Private Shared Sub Main(ByVal args As String())
|
|
Dim student = New Student() With
|
|
{
|
|
.Name = "Steve"
|
|
}
|
|
Dim postTask = client.PostAsJsonAsync(Of Student)("student", student)
|
|
postTask.Wait()
|
|
Dim result = postTask.Result
|
|
|
|
If result.IsSuccessStatusCode Then
|
|
Dim readTask = result.Content.ReadAsAsync(Of Student)()
|
|
readTask.Wait()
|
|
Dim insertedStudent = readTask.Result
|
|
Console.WriteLine("Student {0} inserted with id: {1}", insertedStudent.Name, insertedStudent.Id)
|
|
Else
|
|
Console.WriteLine(result.StatusCode)
|
|
End If
|
|
End Sub
|
|
End Class
|
|
End Namespace
|