WEB SERVICE – VIA REST

Post Reply
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

WEB SERVICE – VIA REST

Post 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 ?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: WEB SERVICE – VIA REST

Post 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" } ) )
regards, saludos

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

Re: WEB SERVICE – VIA REST

Post by Antonio Linares »

Or using curl:

Code: Select all

#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
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: WEB SERVICE – VIA REST

Post by vilian »

Thank you ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: WEB SERVICE – VIA REST

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply