JSON ENCODE DECODE SEND RECEIVE (resuelto)

Post Reply
User avatar
Maggiro
Posts: 76
Joined: Thu Oct 14, 2010 3:26 am
Location: LIMA - PERU
Contact:

JSON ENCODE DECODE SEND RECEIVE (resuelto)

Post by Maggiro »

Buenos Dias Comunidad:
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
 
Desde ya muchas gracias por vuestro alcance ...
Saludos
Julio César Gómez Cortéz
Jultzem Experiencias
Lima - Perú
User avatar
Maggiro
Posts: 76
Joined: Thu Oct 14, 2010 3:26 am
Location: LIMA - PERU
Contact:

Re: JSON ENCODE DECODE SEND RECEIVE (resuelto)

Post by Maggiro »

Gracias al dato recibido por anserkk pude resolver
Muchos Saludos
Julio César Gómez Cortéz
Jultzem Experiencias
Post Reply