TIPClientHttp() - ERROR

Post Reply
Verhoven
Posts: 565
Joined: Sun Oct 09, 2005 7:23 pm

TIPClientHttp() - ERROR

Post by Verhoven »

Buenas tardes a todos,
Tengo un problema con el siguiente código que no soy capaz de resolver y dejo aquí por si alguien me puede aportar algo de luz:

Code: Select all | Expand

#require "hbssl"
#require "hbtip"

PROCEDURE pruebahttps()
   LOCAL cPostData, cResponse
   LOCAL cUrl := "https://api.juanillo.es/json/api/transaction"
   LOCAL oClient := TIPClientHttp():New( cUrl )  // Inicializar el cliente HTTP

   if oClient:Open()
      msginfo(oClient:Open(), "oClient:Open()")
   else
      msginfo(oClient:Open(), "ERROR: oClient:Open()")
      return
   endif

   // Datos a enviar en el cuerpo del POST (por ejemplo, en formato JSON)
   cPostData := '{"clave":"valor", "otro":"dato"}'

   // Configurar la solicitud
   oClient:nConnTimeout := 5000  // Timeout de conexión (5 segundos)
   oClient:lSSL         := .T.   // Habilitar SSL para HTTPS

   // Abrir conexión
   IF oClient:Open()
      // Enviar solicitud POST
      oClient:Post( cPostData, "application/json" )
      cResponse := oClient:cReply

      // Verificar respuesta
      IF !Empty( cResponse )
         msginfo( cResponse, "Respuesta del servidor:")
         msginfo(hb_ValToExp( oHTTP:hHeaders ),"oHTTP:hHeaders")
      ELSE
         msginfo(oClient:LastError(),"Error al enviar la solicitud POST:")
      ENDIF

      // Cerrar conexión
      oClient:Close()
   ELSE
      msginfo(oClient:LastError(),"No se pudo conectar al servidor:")
   ENDIF

RETURN
y el error que se obtiene en ejecución para la línea: LOCAL oClient := TIPClientHttp():New( cUrl ) // Inicializar el cliente HTTP
Application
===========
Path and name: c:\CLIWIN\FW\wintpv_64.exe (64 bits)
Size: 6,524,928 bytes
Compiler version: Harbour 3.2.0dev (r2503251254)
FiveWin version: FWH 25.01
C compiler version: Microsoft Visual C 19.32.31329 (64-bit)
Windows 10 64 Bits, version: 6.2, Build 9200

Time from start: 6 sec
Error occurred at: 14-10-25, 21:42:18
Error description: Error BASE/1081 Operaci¢n no soportada: TIPCLIENTHTTP:new()
Args:
[ 1] = O TIPCLIENTHTTP
[ 2] = C https

Stack Calls
===========
Called from: hbtip\client.prg => TIPCLIENT:NEW( 0 )
Called from: hbtip\httpcli.prg => TIPCLIENTHTTP:NEW( 0 )
Called from: wintpv.prg => PRUEBAHTTPS( 7 )
FiveWiDi
Posts: 1467
Joined: Mon Oct 10, 2005 2:38 pm

Re: TIPClientHttp() - ERROR

Post by FiveWiDi »

Yo probaría así:

...
LOCAL oClient := Nil

oClient := TIPClientHttp():New( cUrl ) // Inicializar el cliente HTTP

if oClient:Open()
....

Un Saludo
Carlos G.

FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home

Verhoven
Posts: 565
Joined: Sun Oct 09, 2005 7:23 pm

Re: TIPClientHttp() - ERROR

Post by Verhoven »

Probado, sigue dando el mismo fallo de operación no soportada.
User avatar
Enrico Maria Giordano
Posts: 9054
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: TIPClientHttp() - ERROR

Post by Enrico Maria Giordano »

You have to link hbssl.lib, libssl-3.lib and libcrypto-3.lib and put libssl-3.dll and libcrypto-3.dll in your directory (or in the path).
Post Reply