Hi Team,
While creating the post request to the code in VB.net I have observed its taking more time to provide the response. could you please let me know what s wrong with my code.
API endpoint which I am consuming is : api/v4/users
Public Async Function InvokeAPIMatterMost(ByVal strJson As String, ByVal MethodName As String, ByVal AsyncService As String) As Threading.Tasks.Task
Dim response As HttpResponseMessage
Dim result As String = String.Empty
Dim responseContent As String = String.Empty
Dim ds As New DataSet
Try
Using client = New HttpClient()
client.BaseAddress = New Uri(AsyncService & MethodName)
client.DefaultRequestHeaders.Accept.Clear()
client.DefaultRequestHeaders.Add("Authorization", "SECREATESGHSJJS")
client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json"))
Dim httpContent = New StringContent(strJson.ToString(), Encoding.UTF8, "application/json")
httpContent.Headers.ContentType.CharSet = Nothing
response = Await client.PostAsync("", httpContent)
result = Await response.Content.ReadAsStringAsync()
ds = ReadDataFromJson(result)
If ds IsNot Nothing AndAlso ds.Tables.Count > 0 Then
DsResult = ds
End If
End Using
Catch ex As Exception
ObjErr.Code = "1"
ObjErr.Message = ex.Message
ObjErr.Ex = ex
Finally
response = Nothing
result = Nothing
responseContent = Nothing
End Try
End Function
Its taking more than 1 to 2 mints to get the response.
please help me where its wrong.