![]() |
|
Delphi 12.2 rmPOST hatası - Baskı Önizleme +- Delphi Can (https://www.delphican.com) +-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3) +--- Forum: Mobil Platform - FireMonkey (FMX) (https://www.delphican.com/forumdisplay.php?fid=7) +--- Konu Başlığı: Delphi 12.2 rmPOST hatası (/showthread.php?tid=7994) |
Delphi 12.2 rmPOST hatası - admar - 30-12-2024 Ben Delphi 12.2 android FMX datasnap REST Client üzerinde çalışıyorum. Bu işlemleri PostgreSQL kullanıyorum. Veri alma gönderme işlemleri için JSON kullanıyrum. Client tarafından Server tarafına gönderme işlemlerini RmPOST hata veriyor. . RmPOST örneği aşağıdaki gibidir. Kod: RESTRequest1.Method := rmPOST;Delphi 12.2 rmPOST hatası - 3ddark - 31-12-2024 Benzeri kullandığım yapı size örnek olsun.
TLoginReq = class
private
[JSONNameAttribute('username')]
FUserName: string;
[JSONNameAttribute('password')]
FUserPass: string;
public
property userName: string read FUserName write FUserName;
property userPass: string read FUserPass write FUserPass;
end;
var
LRestCli: TRESTClient;
LRestRes: TRESTResponse;
LRestReq: TRESTRequest;
jSonLoginReq: TLoginReq;
begin
LRestCli := TRESTClient.Create('');
LRestRes := TRESTResponse.Create(LRestCli);
LRestReq := TRESTRequest.Create(LRestCli);
jSonLoginReq := TLoginReq.Create;
try
LRestCli.ResetToDefaults;
LRestCli.BaseURL := GetServerAddress(ACloudIP, ARestAdres); // http://192.168.xx.xx:xxxx/login
LRestCli.Accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
LRestCli.AcceptCharset := 'utf-8, *;q=0.8';
LRestReq.ResetToDefaults;
LRestReq.Accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
LRestReq.AcceptCharset := 'utf-8, *;q=0.8';
LRestRes.ResetToDefaults;
LRestReq.Resource := 'login';
LRestReq.Method := TRESTRequestMethod.rmPOST;
LRestReq.Response := LRestRes;
jSonLoginReq.userName := ''//Username;
jSonLoginReq.userPass := ''//Password;
LRestReq.Params.AddItem('login', jSonLoginReq.toJSon(jSonLoginReq).toJSon, TRESTRequestParameterKind.pkREQUESTBODY);
LRestReq.Params.Items[0].ContentType := TRESTContentType.ctAPPLICATION_JSON;
try
LRestReq.Execute;
LRestReq.Params.Clear;
except
Exit;
end;
if LRestRes.Content <> '' then
begin
//burada response content geldi.
end;
finally
jSonLoginReq.Free;
LRestCli.Free;
end;
|