I have a vb.net async httpResponse function like this:
Public Async Function getWebserviceResponse(ByVal sb As StringBuilder, ByVal baseUri As Uri, ByVal Method As String, ByVal User As String, ByVal Password As String) As Task(Of HttpResponseMessage)
Dim client As HttpClient = New HttpClient()
client.BaseAddress = baseUri
Dim authHeader As AuthenticationHeaderValue = New AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
String.Format("{0}:{1}", User, Password))))
client.DefaultRequestHeaders.Authorization = authHeader
Dim content As New StringContent(sb.ToString, System.Text.Encoding.UTF8, "application/json")
Dim resp As HttpResponseMessage
Dim cancellationToken As CancellationToken
If Method = "Post" Then
resp = Await client.PostAsync(baseUri, content, cancellationToken)
ElseIf Method = "Put" Then
resp = Await client.PutAsync(baseUri, content, cancellationToken)
End If
Return resp
End Function
The problem is, that "resp" should return a "normal" HttpResponseMessage and not a Task(Of HttpResponseMessage)...
How can I get this? Thank you in advance for your help!
Best regards Martin