Código: Seleccionar todo
METHOD Button2Click( oSender ) CLASS TForm1
LOCAL cTexto, cData, xerro, cJson
LOCAL oInternet, Connection, File
::oMemo1:Value:= ""
BEGIN SEQUENCE
oInternet:= TInternet():New( Self )
oInternet:nPort := INTERNET_DEFAULT_HTTPS_PORT
oInternet:cAgent := "Panel2"
oInternet:nTimeOut:= 60000
IF !oInternet:Open()
BREAK "Not Open"
ENDIF
Connection:= oInternet:Connect("jsonplaceholder.typicode.com")
IF !Connection
BREAK "Not Connection"
ENDIF
cJson:= '{ "title": "foo", "body": "bar", "userId": 1 }'
File:= oInternet:OpenRequest(;
"POST",;
"/posts",;
INTERNET_FLAG_SECURE,;
"HTTP/1.0")
IF !oInternet:SendRequest(;
File,;
"Content-type: application/json",;
cJson )
BREAK "Not SendRequest"
ENDIF
cTexto:=''
WHILE oInternet:ReadFile( File, @cData, 65536 )
cTexto += cData
ENDDO
::oMemo1:Value:= cTexto + " *** "+oInternet:GetErrorDescription()
RECOVER USING xerro
::oMemo1:Value:= oInternet:GetErrorDescription()
MsgInfo( xerro )
END SEQUENCE
Fausto Di Creddo Trautwein