idhttp access DATASNAP password authentication middleware

idhttp access DATASNAP password authentication middleware

With TIDHttp DataSnap Rest access server, the server uses the case of user authentication, clients need to submit a password or can not connect properly.

procedure TForm15.Button2Click(Sender: TObject);
var
  url, params, Text: string;
  code: Integer;
  http: TIDHttp;
begin
  http:= TIDHttp.Create(nil);
  http.Request.BasicAuthentication := True;
  http.request.password := '密码'; // 提交密码
  params := Edit1.Text;

  url:= 'http://192.168.10.182:8081/datasnap/rest/TSM/EchoString/';
  try
    text := http.Get(URL+TIdURI.ParamsEnCode(params));
    Edit2.Text := Text;
  except
    on E: Exception do
    begin

    end;
  end;
end;

  

Guess you like

Origin www.cnblogs.com/hnxxcxg/p/11204825.html