'Llamada get a:
http://api.test.es/v1/get_program_has_result?programId=test&programName=prueba
'Respuesta esperada:
{"data":{"has_result":"yes"}}
Public Class ValidateResult
Public
has_result As String
End Class
Public Class ContainerValidateResult
Public
data As ValidateResult
End Class
Sub getResult()
Try
Dim
webClient As New
System.Net.WebClient
Dim
jsonString As String
= webClient.DownloadString("http://api.test.es/v1/get_program_has_result?programId=test&programName=prueba")
Dim
respuesta As ContainerValidateResult
= JsonConvert.DeserializeObject(Of ContainerValidateResult)(jsonString)
MsgBox(respuesta.data.has_result)
Catch ex As WebException
If
(ex.Status = WebExceptionStatus.ProtocolError)
Then
Dim
responsee As WebResponse
= ex.Response
Using
(responsee)
Dim
httpResponse As HttpWebResponse
= CType(responsee, HttpWebResponse)
Dim
statusCode As HttpStatusCode
= httpResponse.StatusCode
Dim
myStreamReader As StreamReader
= New StreamReader(responsee.GetResponseStream())
Using
(myStreamReader)
Dim ResponseText As String = ""
ResponseText =
myStreamReader.ReadToEnd()
ResponseText =
ResponseText
MessageBox.Show(ResponseText)
End
Using
End
Using
End
If
End Try
End Sub
No hay comentarios:
Publicar un comentario