FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Capturar el motivo del error petici贸n web (curl)
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Capturar el motivo del error petici贸n web (curl)
Posted: Thu Oct 20, 2022 09:33 PM
Hola buenas tardes,
En algunas ocasiones y dependiendo de la maquina desde donde se lance la petici贸n, la aplicaci贸n no logra enviar la solicitud ohttp:Send, nosotros colocamos un mensaje personalizado que indica que no se pudo enviar; existe alguna forma de capturar el motivo especifico por el cual no se pudo enviar la petici贸n.

Cabe aclarar que hay conexi贸n a internet y la url a la cual estamos consultando tambien existe, como digo funciona correctamente en otros computares que est谩n conectados a la misma LAN.

Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽 cBas64 := hb_base64encode(::user+":"+::pass,len(::user+":"+::pass))聽
聽 聽 聽 聽 聽 聽 ohttp := CreateObject( "MSXML2.XMLHTTP" )
聽 聽 聽 聽 聽 聽 ohttp:Open( "POST" , ::urlenvio ,.F.)
聽 聽 聽 聽 聽 聽 oHttp:SetRequestHeader("cache-control", "no-cache")
聽 聽 聽 聽 聽 聽 ohttp:SetRequestHeader("content-type", "application/json" )
聽 聽 聽 聽 聽 聽 ohttp:SetRequestHeader("authorization", "Basic "+cBas64 )
聽 聽 聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 聽 聽 聽 ohttp:Send( ::cdnaJson )
聽 聽 聽 聽 聽 聽 CATCH
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //NOS GUSTARIA PODER CAPTURAR EL ERROR Y SABER EL MOTIVO POR EL QUE NO SE PUDO ENVIAR
聽 聽 聽 聽 聽 聽 聽 聽 msginfo("No Se Pudo Enviar Documento JSON - Error URL","error url")
聽 聽 聽 聽 聽 聽 END
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Fri Oct 21, 2022 05:53 AM
leandro wrote:Hola buenas tardes,
En algunas ocasiones y dependiendo de la maquina desde donde se lance la petici贸n, la aplicaci贸n no logra enviar la solicitud ohttp:Send, nosotros colocamos un mensaje personalizado que indica que no se pudo enviar; existe alguna forma de capturar el motivo especifico por el cual no se pudo enviar la petici贸n.

Cabe aclarar que hay conexi贸n a internet y la url a la cual estamos consultando tambien existe, como digo funciona correctamente en otros computares que est谩n conectados a la misma LAN.

Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽 cBas64 := hb_base64encode(::user+":"+::pass,len(::user+":"+::pass))聽
聽 聽 聽 聽 聽 聽 ohttp := CreateObject( "MSXML2.XMLHTTP" )
聽 聽 聽 聽 聽 聽 ohttp:Open( "POST" , ::urlenvio ,.F.)
聽 聽 聽 聽 聽 聽 oHttp:SetRequestHeader("cache-control", "no-cache")
聽 聽 聽 聽 聽 聽 ohttp:SetRequestHeader("content-type", "application/json" )
聽 聽 聽 聽 聽 聽 ohttp:SetRequestHeader("authorization", "Basic "+cBas64 )
聽 聽 聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 聽 聽 聽 ohttp:Send( ::cdnaJson )
聽 聽 聽 聽 聽 聽 CATCH
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //NOS GUSTARIA PODER CAPTURAR EL ERROR Y SABER EL MOTIVO POR EL QUE NO SE PUDO ENVIAR
聽 聽 聽 聽 聽 聽 聽 聽 msginfo("No Se Pudo Enviar Documento JSON - Error URL","error url")
聽 聽 聽 聽 聽 聽 END


Leandro
Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 聽 聽 聽 ohttp:Send( ::cdnaJson )
                cRet := ohttp:ResponseText
聽 聽 聽 聽 聽 聽 CATCH
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //NOS GUSTARIA PODER CAPTURAR EL ERROR Y SABER EL MOTIVO POR EL QUE NO SE PUDO ENVIAR
聽 聽 聽 聽 聽 聽 聽 聽 msginfo("No Se Pudo Enviar Documento JSON - Error URL","error url")
                ? cRet
聽 聽 聽 聽 聽 聽 END

Tambi茅n has de valorar usar la libreria CURL
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 476
Joined: Sat Feb 03, 2007 06:36 AM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Fri Oct 21, 2022 01:11 PM
Leandro, aparte de lo que te envi贸 Cristobal, tal vez te sirva esto:

Code (fw): Select all Collapse
 聽 聽 
聽 聽 聽 聽 聽 聽 聽TRY
聽 聽 聽 聽 聽 聽 聽 聽 ohttp:Send( ::cdnaJson )
聽 聽 聽 聽 聽 聽 聽 聽 cRet := ohttp:ResponseText
聽 聽 聽 聽 聽 聽 CATCH oError

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgInfo( "Error" + CRLF 聽+ "Error: " + cValToChar( oError:GenCode) + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"SubC: " + cValToChar( oError:GenCode) + CRLF + "OSCode: " + cValToChar( oError:GenCode) + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"SubSystem: " + cValToChar( oError:SubSystem ) + CRLF + "Envio de CURL: " + oError:Description )

聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 //NOS GUSTARIA PODER CAPTURAR EL ERROR Y SABER EL MOTIVO POR EL QUE NO SE PUDO ENVIAR
聽 聽 聽 聽 聽 聽 聽 聽 msginfo("No Se Pudo Enviar Documento JSON - Error URL","error url")
聽 聽 聽 聽 聽 聽 聽 聽 ? cRet
聽 聽 聽 聽 聽 聽 END


Saludos

Carlos.
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Fri Oct 21, 2022 02:32 PM
Muchas gracias por las respuestas, creo que la de Carlos es la que mas se ajusta a nuestra necesidad.

El motivo del error:
Code (fw): Select all Collapse
Error: 1001 SubC: 1001
OSCode: 1001
SubSystem: MSXML2.XMLHTTP
Envio de CURL: DISP_E_MEMBERNOTFOUND


Alguien sabe como lo podemos solucionar?

Amigo Crist贸bal, en donde encuentro ejemplos sobre la librer铆a curl?
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Fri Oct 21, 2022 02:55 PM
leandro wrote:Muchas gracias por las respuestas, creo que la de Carlos es la que mas se ajusta a nuestra necesidad.

El motivo del error:
Code (fw): Select all Collapse
Error: 1001 SubC: 1001
OSCode: 1001
SubSystem: MSXML2.XMLHTTP
Envio de CURL: DISP_E_MEMBERNOTFOUND


Alguien sabe como lo podemos solucionar?

Amigo Crist贸bal, en donde encuentro ejemplos sobre la librer铆a curl?


Entonces es que no te he entendido: si lo que pretendes es capturar un error de programaci贸n o ejecuci贸n, estoy de acuerdo. Si lo que necesitas es capturar si la respuesta del API o servicio web que est谩s atacando te devuelve un c贸digo de error te recomiendo que uses lo que te he puesto y analices el contenido de la respuesta que te da el servidor ( no hay una forma gen茅rica de hacerlo, ya que cada server devolver谩 seg煤n est茅 programado el API o servicio )
En cuanto a la libreria CURL hay bastantes ejemplos en el foro, pero miro a ver si te puedo construir ese mismo ejemplo.
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Sat Oct 22, 2022 02:11 AM
Amigo buenas noches como estas?

Revisando en el foro, puede encontrar un ejemplo que publicaste, para compilar con xharbour, incluyendo la librer铆a hbcur.lib. Pero agregando la funci贸n que colocaste me salen los siguientes errores:

http://forums.fivetechsupport.com/viewtopic.php?f=3&t=40437&p=241434&hilit=curl+xharbour&sid=83943fd443094141a77f5e0834bb4ac0&sid=d699d9e1c47f549e8b8a5829430cb47c#p241692

Tampoco encuentro el #include "hbcurl.ch"

Code (fw): Select all Collapse
Turbo Incremental Link 6.80 Copyright (c) 1997-2017 Embarcadero Technologies, Inc.
Error: Unresolved external '_curl_global_init_mem' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_global_cleanup' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_formfree' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_cleanup' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_reset' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_duphandle' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_init' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_pause' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_perform' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_send' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_recv' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_formadd' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_slist_append' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_setopt' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_getinfo' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_slist_free_all' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_escape' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_unescape' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_version' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_version_info' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_easy_strerror' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_getdate' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_escape' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_unescape' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unresolved external '_curl_free' referenced from C:\XHAR1906\LIB\HBCURL.LIB|hbcurl
Error: Unable to perform link
Link Error


Te agradecer铆a si tienes entre tus cosas un ejemplo funciona para xharbour :-) de antemano gracias.
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Sat Oct 22, 2022 06:03 AM

A帽ade las librerias libcurl.lib y hbcurl.lib

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Sat Oct 22, 2022 02:48 PM
Amigo de nuevo gracias por responder

Agregue las librer铆as como mencionaste, permiti贸 compilar, agregue hbcurl.ch, tambien me pidi贸 la libcurl.dll, la cual copie en la carpeta al lado del ejecutable.

Pero al lanzar la funci贸n ejemplo sale el siguiente error:

Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Wed Nov 02, 2022 02:06 AM
Buenas noches para todos
Error: 1001 SubC: 1001
OSCode: 1001
SubSystem: MSXML2.XMLHTTP
Envio de CURL: DISP_E_MEMBERNOTFOUND
hemos logrado detectar que el error mencionado con anterioridad, solo sale cuando direccionamos al servidor nuevo, en el anterior funciona de manera correcta. De casualidad alguien sabe a que se pueda deber? es necesario instalar alg煤n complemento en el nuevo servidor, algo de seguridad?

Cabe recordar que solo sucede en algunos computadores, sobre todo en los que tienen windows7.

y que la prueba se hizo en el mismo computador y lo 煤nico que cambiamos fue la direcci贸n web.

Cuando lo direccionamos al servidor https://hymplus.com/servicios/autorizados funciona correctamente

pero al direccionarlo al servidor https://hymlyma.com/servicios/autorizados es en donde sale el error
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Sat Nov 05, 2022 09:06 PM
Buenas tardes para todos

Bueno les cuento que buscando solucionar este problema que tenemos, logramos compilar la aplicaci贸n con harbour, como nos recomend贸 Cristobal, estamos intentando usar la libreria curl, el problema ahora es que no logramos que el servidor nos entregue una respuesta. Necesitamos ayuda para traducir el c贸digo que ven铆amos usando por el de la libreria curl.

C贸digo anterior
Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽 cBas64 := hb_base64encode(::user+":"+::pass,len(::user+":"+::pass))
聽 聽 聽 聽 聽 聽 ohttp := CreateObject( "MSXML2.XMLHTTP" )
聽 聽 聽 聽 聽 聽 ohttp:Open( "POST" , ::urlenvio ,.F.)
聽 聽 聽 聽 聽 聽 oHttp:SetRequestHeader("cache-control", "no-cache")
聽 聽 聽 聽 聽 聽 ohttp:SetRequestHeader("content-type", "application/json" )
聽 聽 聽 聽 聽 聽 ohttp:SetRequestHeader("authorization", "Basic "+cBas64 )
聽 聽 聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 聽 聽 聽 ohttp:Send( ::cdnaJson )
聽 聽 聽 聽 聽 聽 聽 聽 response := 聽ohttp:responseText
聽 聽 聽 聽 聽 聽 CATCH oError
聽 聽 聽 聽 聽 聽 聽 聽 cError := "Error: " + cValToChar( oError:GenCode) + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 " SubC: " + cValToChar( oError:GenCode) + " OSCode: " + cValToChar( oError:GenCode) + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "SubSystem: " + cValToChar( oError:SubSystem ) + CRLF + "Envio de CURL: " + oError:Description 
聽 聽 聽 聽 聽 聽 聽 聽 exito := {.f.,cError}

聽 聽 聽 聽 聽 聽 聽 聽 return exito
聽 聽 聽 聽 聽 聽 END
C贸digo con curl, que encontramos en el foro
Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽 cBas64 := hb_base64encode(::user+":"+::pass,len(::user+":"+::pass))
聽 聽 聽 聽 聽 聽 curl_global_init()
聽 聽 聽 聽 聽 聽 hCurl := curl_easy_init()
聽 聽 聽 聽 聽 聽 if !empty( hCurl )

聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_URL, ::urlenvio )
聽 聽 聽 聽 聽 聽 聽 聽 AAdd( aHeaders, "authorization: Basic "+cBas64 ) 
聽 聽 聽 聽 聽 聽 聽 聽 AAdd( aHeaders, "content-type : application/json" ) 聽 
聽 聽 聽 聽 聽 聽 聽 聽 AAdd( aHeaders, "cache-control : no-cache" ) 聽 
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, aHeaders )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_CONNECTTIMEOUT , 100 )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1)
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_CUSTOMREQUEST, "POST")
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, ::cdnaJson )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYHOST, .F. )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )

聽 聽 聽 聽 聽 聽 聽 聽 cError := curl_easy_perform( hCurl )
聽 聽 聽 聽 聽 聽 聽 聽 if !Empty( cError )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgInfo( curl_easy_strerror( cError ), "Error" )
聽 聽 聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽 聽 聽 cTexto 聽:= curl_easy_dl_buff_get( hCurl )
聽 聽 聽 聽 聽 聽 聽 聽 fw_memoedit( cTexto ) //Creo que aqui viene la respuesta 
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_reset( hCurl )
聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽 curl_global_cleanup()
Este es el error que se captura en el fw_memoedit()
Code (fw): Select all Collapse
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
Luego de esto la aplicaci贸n se cierra sin que muestre ning煤n error y tampoco genera el error en el archivo error.log

De antemano gracias por la ayuda
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Sat Nov 05, 2022 10:18 PM
Mira a ver si algo de esto te ayuda
Code (fw): Select all Collapse
聽 聽 聽 curl_easy_setopt( oCurl, HB_CURLOPT_SSL_VERIFYPEER, 0 )
聽 聽 聽 curl_easy_setopt( oCurl, HB_CURLOPT_ENCODING, "UTF-8" )

聽 聽 聽 Do Case
聽 聽 聽 聽 聽 Case cType == "POST"
聽 聽 聽 聽 聽 聽 聽 聽 聽curl_easy_setopt( oCurl, HB_CURLOPT_DL_BUFF_SETUP )
聽 聽 聽 聽 聽 聽 聽 聽 聽curl_easy_setopt( oCurl, HB_CURLOPT_POST, 1 )
聽 聽 聽 聽 聽// 聽 //curl_easy_setopt( oCurl, HB_CURLOPT_CUSTOMREQUEST, "POST" )
聽 聽 聽 聽 聽 聽 聽 聽 if !Empty( cParams )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( oCurl, HB_CURLOPT_POSTFIELDS, cParams )
聽 聽 聽 聽 聽 聽 聽 聽endif
聽 聽 聽EndCase
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Sat Nov 05, 2022 11:43 PM
No nada, sigue igual :(
Code (fw): Select all Collapse
聽 聽 聽 聽 聽 聽 curl_global_init()
聽 聽 聽 聽 聽 聽 hCurl := curl_easy_init()
聽 聽 聽 聽 聽 聽 if !empty( hCurl )

聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_URL, ::urlenvio )
聽 聽 聽 聽 聽 聽 聽 聽 AAdd( aHeaders, "authorization: Basic "+cBas64 ) 
聽 聽 聽 聽 聽 聽 聽 聽 AAdd( aHeaders, "content-type : application/json" ) 聽 
聽 聽 聽 聽 聽 聽 聽 聽 AAdd( aHeaders, "cache-control : no-cache" ) 聽 
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_HTTPHEADER, aHeaders )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_CONNECTTIMEOUT , 100 )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1)
聽 聽 聽 聽 聽 聽 聽 聽 //curl_easy_setopt( hCurl, HB_CURLOPT_CUSTOMREQUEST, "POST")
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, ::cdnaJson )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYHOST, .F. )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_SSL_VERIFYPEER, .F. )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_setopt( hCurl, HB_CURLOPT_ENCODING, "UTF-8" )

聽 聽 聽 聽 聽 聽 聽 聽 cError := curl_easy_perform( hCurl )
聽 聽 聽 聽 聽 聽 聽 聽 if !Empty( cError )
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 MsgInfo( curl_easy_strerror( cError ), "Error" )
聽 聽 聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽 聽 聽 cTexto 聽:= curl_easy_dl_buff_get( hCurl )
聽 聽 聽 聽 聽 聽 聽 聽 fw_memoedit( cTexto ) //Creo que aqui viene la respuesta 
聽 聽 聽 聽 聽 聽 聽 聽 curl_easy_reset( hCurl )
聽 聽 聽 聽 聽 聽 endif
聽 聽 聽 聽 聽 聽 curl_global_cleanup()
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Sun Nov 06, 2022 02:46 AM
A帽ade al principio
Code (fw): Select all Collapse
聽 聽 聽 curl_easy_setopt( oCurl, HB_CURLOPT_DEFAULT_PROTOCOL, "https" )
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Sun Nov 06, 2022 11:52 AM
Amigo gracias por la ayuda

Ahora sale este error:
Code (fw): Select all Collapse
Application
===========
聽 聽Path and name: C:\DLYMA\hymlyma.exe (32 bits)
聽 聽Size: 8,435,200 bytes
聽 聽Compiler version: Harbour 3.2.0dev (r2008190002)
聽 聽FiveWin 聽version: FWH 21.06
聽 聽C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
聽 聽Windows version: 6.2, Build 9200 

聽 聽Time from start: 0 hours 0 mins 35 secs 
聽 聽Error occurred at: 06/11/2022, 06:51:16
聽 聽Error description: Error BASE/1003 聽No existe la variable: HB_CURLOPT_DEFAULT_PROTOCOL
Saludos
LEANDRO AREVALO
Bogot谩 (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Capturar el motivo del error petici贸n web (curl)
Posted: Sun Nov 06, 2022 01:37 PM
#define HB_CURLOPT_DEFAULT_PROTOCOL 0x072d00
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces