WEB SERVICE – VIA REST

WEB SERVICE – VIA REST

Postby vilian » Wed Feb 19, 2020 6: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
User avatar
vilian
 
Posts: 978
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: WEB SERVICE – VIA REST

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WEB SERVICE – VIA REST

Postby Antonio Linares » Thu Feb 20, 2020 10:28 am

Or using curl:

Code: Select all  Expand view  RUN
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: WEB SERVICE – VIA REST

Postby vilian » Thu Feb 20, 2020 10:53 am

Thank you ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 978
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: WEB SERVICE – VIA REST

Postby Antonio Linares » Fri Feb 21, 2020 11:46 am

This is also quite interesting :-)

viewtopic.php?f=45&t=38511&start=0
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 58 guests