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 ?
WEB SERVICE – VIA REST
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: WEB SERVICE – VIA REST
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" } ) )
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" } ) )
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: WEB SERVICE – VIA REST
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: