Peguei no grupo do harbour.
sendpost.prg
*
#require "hbcurl"
*
FUNCTION SendPost()
*
// Example how to send JSON data on REST web service
// Example use POST method and cUrl
// It works for me
// I made it slightly modifying example found in Harbour forum on nexe link:
// https://groups.google.com/forum/#!searchin/harbour-users/curl$20claudia|sort:date/harbour-users/yKF_6WAdCJ4/dTxh6qIuBQAJ
*
LOCAL aHeader:={},curl,res1,ccl,ncurlErr,ncode
// REST web service link:
LOCAL sUrl:="https://ws.aaa.bb/Kat/methodname1"
// JSON data to send
LOCAL cJsonData:='{"key1":"value1", "key2":"value2", "key3":"value3" }'
*
curl_global_init()
*
aHeader:={}
AADD(aHeader,"Content-Type: application/json")
*
IF ! Empty( curl := curl_easy_init() )
// specify header
curl_easy_setopt(curl,HB_CURLOPT_HTTPHEADER,aHeader)
// set endpoint to send the POST to
res1:=curl_easy_setopt(curl,HB_CURLOPT_URL,sUrl)
// do not verify peer with CA cerftificate
// im my case do not need verification
curl_easy_setopt(curl,HB_CURLOPT_SSL_VERIFYPEER,.F.)
curl_easy_setopt(curl,HB_CURLOPT_SSL_VERIFYHOST,.F.)
// set response data
curl_easy_setopt(curl,HB_CURLOPT_DOWNLOAD)
curl_easy_setopt(curl,HB_CURLOPT_DL_BUFF_SETUP)
// specify POST data
** do not need this: curl_easy_setopt(curl,HB_CURLOPT_POST, 1)
** because command below already did it
curl_easy_setopt(curl,HB_CURLOPT_POSTFIELDS,cJsonData)
* put .T. when testing, put .F. in production
curl_easy_setopt(curl,HB_CURLOPT_VERBOSE,.T.)
ncurlErr:=curl_easy_perform (curl)
IF ncurlErr > 0
?"Curl Error: "+str(ncurlErr)
wait
ENDIF
ncode:=curl_easy_getinfo(curl,HB_CURLINFO_RESPONSE_CODE)
IF ncurlErr==0
// store response in variable
ccl:=curl_easy_dl_buff_get(curl)
ELSE
ccl:="Curl error"
ENDIF
?"CCL=",ccl
wait
/* Cleanup session */
curl_easy_cleanup( curl )
curl_global_cleanup()
ENDIF
RETURN NIL
main.hbp
-inc
-omain
-prgflag=-a -m -n -w0 -es0 -b
-gui
-gtwvt
-lcurl
hbnf.hbc
hbformat.hbc
hbfoxpro.hbc
xhb.hbc
hbwin.hbc
hbziparc.hbc
hbssl.hbc
hbtip.hbc
hbcurl.hbc
sendpost1.prg
Deixando aqui, para quando precisar.
Saudações,
Itamar M. Lins Jr.