Title: REST question Post by: Andrew.W on June 13, 2017, 10:42:45 AM Hi Daniel
I'm trying to setup a simple REST client using RTC. I'm using one of the test functions here. http://www.jsontest.com/ and specifically this function http://ip.jsontest.com/ Can I check with you: - Are the right client components TRtcHttpClient and TRtcClientModule? - What should the value of DataFormat be? Thanks Title: Re: REST question Post by: D.Tkalcec (RTC) on June 13, 2017, 11:10:53 AM Expecting the name of the function as part of the sub-domain and making everything accessible from the root URI is the WORST possible use of HTTP - EVER. Also, as far as I can tell, most tests on that page do NOT require any parameters in JSON format, which makes me wonder how that page qualifies as a "JSON test".
Anyway ... this piece of code should do what you wanted ... var Res:TRtcValue; begin RtcHttpClient1.ServerAddr:='ip.jsontest.com'; RtcHttpClient1.ServerPort:='80'; RtcHttpClient1.AutoConnect:=True; RtcClientModule1.Client:=RtcHttpClient1; RtcClientModule1.DataReqMode:=req_queryNameText; RtcClientModule1.DataFormat:=fmt_JSON; RtcClientModule1.Prepare(''); Res:=RtcClientModule1.Execute(False); try if Res.isType=rtc_Record then Label1.Caption:='IP = '+Res.asRecord.asText['ip']; finally Res.Free; end; end; Best Regards, Danijel Tkalcec Title: Re: REST question Post by: Andrew.W on June 13, 2017, 05:32:15 PM Thanks Daniel
|