Update 20211218
This commit is contained in:
30
DPMHttp/Class1.cs
Normal file
30
DPMHttp/Class1.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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
|
||||
Reference in New Issue
Block a user