FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour WEB SERVICE – VIA REST
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
WEB SERVICE – VIA REST
Posted: Wed Feb 19, 2020 06:37 PM

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 ?

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: WEB SERVICE – VIA REST
Posted: Thu Feb 20, 2020 10:06 AM

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" } ) )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: WEB SERVICE – VIA REST
Posted: Thu Feb 20, 2020 10:28 AM
Or using curl:

Code (fw): Select all Collapse
#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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: WEB SERVICE – VIA REST
Posted: Thu Feb 20, 2020 10:53 AM

Thank you ;)

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: WEB SERVICE – VIA REST
Posted: Fri Feb 21, 2020 11:46 AM

This is also quite interesting :-)

viewtopic.php?f=45t=38511start=0

&&

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion