Delphi调用REST很简单,首先在界面上放上:

RESTClient1: TRESTClient;
RESTRequest1: TRESTRequest;
RESTResponse1: TRESTResponse;

然后简单调用即可:

RESTClient1.BaseURL:=edtURL.Text;
RESTRequest1.Execute;
memLog.Text:=RESTResponse1.Content;

还可以对结果进行进一部处理,比如解析JSON:

procedure TfrmMain.btnGetClick(Sender: TObject);
var
jo,jo2:TJSONObject;
jv:TJSONValue;
ja:TJSONArray;
jp:TJSONPair;
i:Integer;
begin
RESTClient1.BaseURL:=edtURL.Text;
RESTRequest1.Execute;
memLog.Text:=RESTResponse1.Content; jo:=TJSONObject.Create;
ja:=jo.ParseJSONValue(RESTResponse1.Content) as TJSONArray;
for jv in ja do
begin
jo2:=jv as TJSONObject;
for i:= to jo2.Count- do
begin
jp:=jo2.Pairs[i];
memLog.Lines.Add(jp.JsonString.ToString+':'+jp.JsonValue.ToString);
end;
end; end;

在这里我使用的是Delphi自带的JSON解析,注意引用单元system.json。

Delphi调用REST的更多相关文章

  1. Delphi 调用C# DLL(包含委托)

    例子 C# Dll: using System; using System.Collections.Generic; using System.Text; using System.Diagnosti ...

  2. delphi调用web service出现 Unable to retrieve the URL endpoint for Service/Port .....

    delphi调用web service出现 Unable to retrieve the URL endpoint  for Service/Port, 错误截图如下 查了很长时间, 发现在DataM ...

  3. Delphi 调用外部程序并等待其运行结束

    转自:http://blog.csdn.net/xieyunc/article/details/4140620   如何让Delphi调用外部程序并等待其运行结束 1. uses     Window ...

  4. fastscript调用delphi方法和DELPHI调用FASTSCRIPT方法

    fastscript调用Delphi过程:  1. 先创建事件处理方法:TfsCallMethodEvent 2. 然后再用调用TfsScript.AddMethod方法,第一个参数为Delphi方法 ...

  5. 【转】Delphi调用webservice总结

    原文:http://www.cnblogs.com/zhangzhifeng/archive/2013/08/15/3259084.html Delphi调用C#写的webservice 用delph ...

  6. Delphi 调用netsh命令修改IP地址

    Delphi 调用netsh命令修改IP地址 先介绍一下Netsh命令的使用方法: 在这里跟大家介绍几个简单的指令 1.Show IP 1.1Cmd Mode 直接在cmd下面输入 netsh int ...

  7. 教程-Delphi调用C# WEBSERVICE(二)

    第二步:将webserivce的WSDL导入到该dll工程中,如何导,方法至少有两种,我说简单的一种:  file->new->other->WebService->WSDL ...

  8. [转]Delphi调用cmd的两种方法

    delphi调用cmd的两种方法vars:string;begins:='cmd.exe /c '+edit1.Text+' >c:\1.txt';winexec(pchar(s),sw_hid ...

  9. Delphi调用webservice总结

    Delphi调用webservice总结     Delphi调用C#写的webservice 用delphi的THTTPRIO控件调用了c#写的webservice. 下面是我调试时遇到的一些问题: ...

随机推荐

  1. Zyxel Switch-How to block a fake DHCP server without enabling DHCP snooping?

    How to block a fake DHCP server without enabling DHCP snooping? Scenario How to block a fake DHCP se ...

  2. Android 中pid与uid的作用与区别

    PID:为Process Identifier, PID就是各进程的身份标识. 程序一运行系统就会自动分配给进程一个独一无二的PID.进程中止后PID被系统回收,可能会被继续分配给新运行的程序,但是在 ...

  3. PAT (Advanced Level) Practise:1008. Elevator

    [题目链接] The highest building in our city has only one elevator. A request list is made up with N posi ...

  4. 跨域之-jquery操作

    在JQ进行跨域的操作,用的是jsonp的方式,创建script标签,除了跨域的行为外,本地的操作方式都是xmlHttpRequest.

  5. ubuntu12.04+kafka2.9.2+zookeeper3.4.5的伪分布式集群安装和demo(java api)测试

    博文作者:迦壹 博客地址:http://idoall.org/home.php?mod=space&uid=1&do=blog&id=547 转载声明:可以转载, 但必须以超链 ...

  6. CMD规范

    define(function (require, exports, module) { module.exports = require('xx/xx/xx')({}); });

  7. JSTL中的scope属性

    前两天接到老大一个任务:要验证一下<c:import>能否动态地引入不同的文件.当时很兴奋,要知道在对日外包里面,这个也得算技术活了.呵呵! 说干就干,写了两个jsp文件:m.jsp  t ...

  8. CentOS 7 php留言本网站的搭建

    一如既往的先搭建yum仓库 并且安装httpd服务 yum install httpd -y 1:改网页的搭建是基于html搭建 查询是否安装该协议 rpm -qa |grep httpd 2:留言板 ...

  9. SQL Server 2012将数据库备份到网络中的共享文件夹

    把计算机computer1 中的数据库备份到计算机computer2(IP:192.168.0.130)中的一个共享文件夹下 在computer2中的F盘下建一个共享文件夹叫DBBackupShare ...

  10. PHP函数getopt详解

    短参数 它返回一个包含命令行参数的数组.比如,要获得-a -b 和-c的值,可以这么做: $arguments = getopt("a:b:c:"); 可以用下面的方式运行脚本(有 ...