I am having an issue where a post WebApi method is not returning a response to the consuming client.
The client is another controller in the same solution/website (for testing purposes)
When I remove the Authorize attribute from the Post method everything works as expected and I recieve the response from the post method.
Client Method calling the post method
Dim postUri As String = "1/client/DataXChangeTester/type/CollisionReport"
Dim leftChild As New QueryNode With {.NodeValue = "drivers.name.lastName"}
Dim rightChild As New QueryNode With {.NodeValue = "McNear"}
Dim simpleOperation As New QueryNode With {.NodeValue = "is",
.LeftNode = leftChild,
.RightNode = rightChild}
Dim queryToSend As QueryDetails = New QueryDetails With {.QueryDetail = simpleOperation}
TesterClient = New HttpClient(HawkClientHandler)
'TesterClient = New HttpClient()
Dim webAddress As String = ConfigurationManager.AppSettings("ServiceURL")
TesterClient.BaseAddress = New Uri(webAddress)
TesterClient.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json"))
Dim action = TesterClient.PostAsync(postUri, queryToSend, New JsonMediaTypeFormatter())
'30 second timeout.
action.Wait(30000)
Dim response As HttpResponseMessage = action.Result
If response.IsSuccessStatusCode Then
ViewData("PredefinedQueryMessage") = response.Content.ReadAsStringAsync().Result
Return View("Index")
Else
ViewData("PreDefinedQueryErrorMessage") = response.Content.ReadAsStringAsync().Result
Return View("Index")
End If
TestCredential = New HawkCredential With {
.Id = "BuyCrashTN",
.Algorithm = "sha256",
.Key = "1531d118-ae19-11e3-b324-28cfe9215d9f"}
HawkClientHandler = New HawkClientMessageHandler(New HttpClientHandler(), TestCredential)
Dim handler As New HawkMessageHandler(New HttpControllerDispatcher(config),
Function(credential)
Return Task.FromResult(RetrieveCredential(credential))
End Function)
'POST 'api/1/client/ClientName/type/TypeName
<Authorize>
<AcceptVerbs("POST")>
Public Function Query(requestMessage As HttpRequestMessage,
clientId As String,
typeName As String,
<FromBody> requestedQuery As QueryDetails) As HttpResponseMessage
Dim responseContents As New QueryResults()
Dim response As HttpResponseMessage
Dim requestId As Integer = -1
Try
requestId = LogRequest("Received Query", requestedQuery)
ReportType = GetType(DataXChangeCollisionQuery)
Parameter = Expression.Parameter(ReportType, "report")
responseContents = ExecuteQuery(requestedQuery)
response = requestMessage.CreateResponse(HttpStatusCode.OK, responseContents)
Catch ex As Exception
response = requestMessage.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error Processing Provided Query")
End Try
LogRequest("Exiting Query Operation", requestedQuery, requestId)
Return response
End Function