Code: Select all
function Main()
local odoc := CreateObject( "MSXML2.DOMDocument" )
local ohttp := CreateObject( "MSXML2.XMLHTTP" )
local strret
ohttp:Open( "GET" ,"http://www.w3schools.com/angular/customers.php", .F. )
ohttp:SetRequestHeader( "Accept" , "application/xml")
ohttp:SetRequestHeader( "Content-Type" ,"application/json" )
oDoc:async := .f.
oDoc:LoadXml('<?xml version=""1.0"" encoding=""utf-8""?>')
ohttp:Send(oDoc:xml)
strret := alltrim(ohttp:responseText)
? strret
StrToHashArray( StrRet )
return nil
function StrToHashArray( cStr )
local hHash, aHash
cStr := CharRepl( "[]", RangeRem( 1, 31, cStr ), "{}" )
do while '" :' $ cStr
StrTran( cStr, '" :', '":' )
enddo
cStr := StrTran( cStr, '":', '"=>' )
hHash := &cStr
aHash := HGetValueAt( hHash, 1 )
xbrowser aHash setup ( obrw:autofit(), oBrw:bRClicked := { |r,c,f,o| o:ToDbf( "download.dbf", nil, nil, .t. ) } )
return nil
The sending statement is in the format:
Code: Select all
oHttp:=TIpClientHttp():new("https://testserver.com/data/1", .F. )
cJson := '{"partid":"147A964","productDataid":"PR123","locationid":"10000"}'
cRet := ""
IF .NOT. oHttp:open()
MsgAlert( "Connection error:", oHttp:lastErrorMessage( ) )
ELSE
oHttp:Post( cJson)
cRet := oHttp:readAll( )
oHttp:close()
ENDIF
nFileHandle := FCreate( "retdata.txt" )
FWrite( nFileHandle, cRet )
FClose( nFileHandle )
Thanks so much.
Tim
For XML data I have been using