Home > Back-end >  How to use Delphi RestClient read flow data?
How to use Delphi RestClient read flow data?

Time:09-24

[the problem has been released in reward for http://ask.csdn.net/questions/239335, please repeat moderator discretion processing]
OANDA website provides a REST API can read the account information (https://api-fxtrade.oanda.com/v1/accounts), as well as offer flow "(streaming, such as" https://stream-fxtrade.oanda.com/v1/prices? AccountId=12345 & amp; Instruments=AUD_CAD % 2 caud_chf "),

Currently in XE7 version, using Delphi provide RestClient components can realize read the account information, but for stream data from the server, because its means of transmission is chunked transfer encoding, according to the account data read way will stop in at the last Excute cannot get the returned Json string,

The code is as follows:
 
The function GetStreamingPrices: TQJson
Var
...
The begin
Result:=TQJson. Create;
//Get
_RESTRequest. Method:=rmGET;
//specified resource location: '/prices
_RESTRequest. Resource:=TRequestSourceURITemplate. Prices;
//generated query string: accountId=12345 & amp; Instruments=AUD_CAD % 2 caud_chf
_RESTRequest. AddParameter (TQueryPairKey AccountID, accountlist [0], pkGETorPOST);
_RESTRequest. AddParameter (TQueryPairKey. Instruments, 'EUR_USD, pkGETorPOST);
//URL
='https://stream-fxtrade.oanda.com/v1'. _RestClient. BaseURL:;
//execution
_RestRequest. Execute;
//resolved as Json
Result. TryParse (_RESTResponse);
end;



So, ask, how to use Delphi XE7 RestClient for chunked transfer encoding streaming data? Please feel free to comment,

CodePudding user response:

Yourself, the solution described here at http://ask.csdn.net/questions/239335#
  • Related