Page 1 of 1
WEB SERVICE – VIA REST
Posted: Wed Feb 19, 2020 6:37 pm
by vilian
Hi Guys,
I need send to a webservice(webserver.averba.com.br/rest/Auth) this content:
Header: Accept: application/json
Content-type: application/json
Body:
{ "usuario": "teste", "senha": "teste", "codigoatm": "11000000" }
Do you know how could I to do this ?
Re: WEB SERVICE – VIA REST
Posted: Thu Feb 20, 2020 10:06 am
by Antonio Linares
Vilian,
oServer := CreateObject( "MSXML2.XMLHTTP" )
oServer:Open( "GET", "webserver.averba.com.br/rest/Auth" )
oServer:SetRequestHeader( "Content-Type", "application/json" )
oServer:Send( hb_jsonEncode( { "usuario" => "teste", "senha" => "teste", "codigoatm" => "11000000" } ) )
Re: WEB SERVICE – VIA REST
Posted: Thu Feb 20, 2020 10:28 am
by Antonio Linares
Or using curl:
Code: Select all | Expand
#include "hbcurl.ch"
function SendAuth()
local uValue
curl_global_init()
if ! empty( hCurl := curl_easy_init() )
curl_easy_setopt( hCurl, HB_CURLOPT_POST, 1 )
curl_easy_setopt( hCurl, HB_CURLOPT_URL, "webserver.averba.com.br/rest/Auth" )
curl_easy_setopt( hCurl, HB_CURLOPT_DL_BUFF_SETUP )
curl_easy_setopt( hCurl, HB_CURLOPT_POSTFIELDS, hb_jsonEncode( { "usuario" => "teste", "senha" => "teste", "codigoatm" => "11000000" } ) )
if curl_easy_perform( hCurl ) == 0
uValue = curl_easy_dl_buff_get( hCurl )
endif
endif
curl_global_cleanup()
return uValue
Re: WEB SERVICE – VIA REST
Posted: Thu Feb 20, 2020 10:53 am
by vilian
Thank you

Re: WEB SERVICE – VIA REST
Posted: Fri Feb 21, 2020 11:46 am
by Antonio Linares