JSON ENCODE DECODE SEND RECEIVE (resuelto)
Posted: Sat Jul 14, 2018 10:02 pm
Buenos Dias Comunidad:
Me preguntaba si éste tipo de rutina puede hacerse en xharbour + fivewin ...
Desde ya muchas gracias por vuestro alcance ...
Saludos
Julio César Gómez Cortéz
Jultzem Experiencias
Lima - Perú
Me preguntaba si éste tipo de rutina puede hacerse en xharbour + fivewin ...
Code: Select all
Private Function EnviarJson(ByVal documento As String, ByVal documento64bytes As String) As String
Dim respuesta As String = ""
Dim user As String = "20557103920ad_escon"
Dim pass As String = "Escon2018"
Dim rss_datos As JObject =
New JObject(New JProperty("customer",
New JObject(
New Jproperty("username", user),
New Jproperty("password", pass))),
New JProperty("filename", documento),
New JProperty("filecontent", documento64bytes))
Try
Dim uri As New Uri("http://calidad.escondatagate.net/wsparser/rest/parserWS")
Dim data As String = rss_datos.ToString()
If (uri.Scheme = uri.SchemeHttp) Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Post
request.ContentLength = data.length
request.ContentType = "application/json"
Dim writer As New StreamWriter(Request.GetRequestStream())
writer.write(data)
writer.Close()
Dim Response As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(response.GetResponsestream())
Dim tmp As String = reader.ReadToEnd()
response.Close()
End If
Catch ex As Exception
respuesta = "-1"
End Try
Return respuesta
Saludos
Julio César Gómez Cortéz
Jultzem Experiencias
Lima - Perú