FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TipClientHttp
Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
TipClientHttp
Posted: Fri Jul 11, 2014 07:18 AM
Hi All

How can I do basic authentification

I retrieve a Uri

oHttp:= TIpClientHttp():new("http://localhost:8080/accountright" )
if oHttp:open()
cItems := oHttp:ReadAll()
else
MsgInfo( "Connection error:" + oHttp:lastErrorMessage())
endif

hb_jsondecode( cItems, @hJson )
for i := 1 to len(hJson)
cId := hJson[i,"Name"]
if substr(cId,1,3) == 'Kas'
cUri := hJson[i,"Uri"]
endif
next
cBasic := hb_base64Encode('user:pass') // username password

I need to send cBasic with the cUri but dont how how.

Regards

Colin
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: TipClientHttp
Posted: Fri Jul 11, 2014 08:06 AM
Colin,

Code (fw): Select all Collapse
oHttp:UseBasicAuth()


EMG
Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
Re: TipClientHttp
Posted: Sat Jul 12, 2014 12:45 AM

Hi Enrico

Thanks I have it working.
oUrl := TUrl():new( cUri )
oUrl:cUserid := 'user'
oUrl:cPassword := 'pass'
oHttp1:= TIpClientHttp():new( oUrl, .T. )
oHttp1:UseBasicAuth()
if oHttp1:open()
cItems2 := oHttp1:ReadAll()
MEMOWRIT( "MYRESULT1.TXT", cItems2 )
else
MsgInfo( "Connection error:" + oHttp1:lastErrorMessage())
endif

Regards

Colin

Continue the discussion