zoukankan      html  css  js  c++  java
  • TRestClient

    TRestClient

    Delphi XE6开始,REST Client系列元件渐渐开始成为 Delphi 团队的重点开发项目之一。TRESTClient, TRESTRequest, TRESTResponse 系列组合。

    var
      jo: TJSONObject;
    begin
      jo:= TJSONObject.Create;
      try
        ResetRESTComponentsToDefaults;
     
        RESTClient.BaseURL := 'http://ynmiddle:9999/';
        RESTClient.Authenticator := HTTPBasicAuthenticator1;
        RESTClient.ContentType := 'application/x-www-form-urlencoded';
     
        RESTRequest.Method := TRESTRequestMethod.rmPOST;
        RESTRequest.Resource := 'oauth/token';
     
        HTTPBasicAuthenticator1.Username := 'orbid-hml';
        HTTPBasicAuthenticator1.Password := EmptyStr;
     
        jo.AddPair('scope', 'product:show stock:save stock:update warehouse:list warehouse:save warehouse:show '+
                                     'warehouse:update partnerOrder:show partnerOrder:list partnerOrder:update');
        jo.AddPair('grant_type', 'client_credentials');
     
        RESTRequest.Params.Clear;
        RESTRequest.Params.AddHeader('authorization', 'Basic '+Edt_Base64.Text);
        RESTRequest.AddBody(jo);
     
     
        RESTRequest.Execute;
        memLog.Text:=RESTResponse1.Content;
      finally
        FreeAndNil(jo);
      end;
    end;

      

  • 相关阅读:
    《梦断代码》随笔第1篇
    四则运算3
    1、软件工程结对开发之求一维数组中连续最大子数组之和
    四则运算2单元测试
    《梦断代码》随笔第0篇
    四则运算2完整版
    四则运算2设计思想
    软件工程第一个程序
    软件工程阅读计划
    电梯调度之需求分析
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/13447634.html
Copyright © 2011-2022 走看看