How can I consume a oData webservice from Delphi (I'm trying to interact with the new Bing Search Azure API)? There is almost no information to do this in Delphi. There is a post here but it does not help much explaining how to consume such service from a Delphi point of view. Can anyone provide a simple example?
Here is a very simple example of consuming an oData service in Delphi XE using the netflix oData service:
program oDataDemo;
{$APPTYPE CONSOLE}
uses
SysUtils, msxml, Variants, Activex;
var
httpRequest: IXMLHttpRequest;
oDataServiceURI: String;
oDataFilter: String;
xmlResults: String;
begin
try
oDataServiceURI := 'http://odata.netflix.com/v2/Catalog/Titles()';
oDataFilter := '?$top=10';
coinitialize(nil);
httpRequest := CoXMLHTTP.Create;
httpRequest.open('GET', UTF8Encode(oDataServiceURI + oDataFilter), false, EmptyParam, EmptyParam);
httpRequest.send(EmptyParam);
xmlResults := httpRequest.responseText;
WriteLn(xmlResults);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With