Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
procedure TForm1.SessionClick(Sender: TObject);
var
JObj: TJSONObject;
sToken: String;
begin
RESTRequest1.ResetToDefaults;
RESTClient1.ResetToDefaults;
RESTResponse1.ResetToDefaults;
RESTClient1.BaseURL := 'http://dreamfactory.app/api/v2';
RESTRequest1.Resource := 'user/session';
RESTRequest1.Accept := 'application/json';
RESTRequest1.Method := TRESTRequestMethod.rmPOST;
JObj := TJSONObject.Create;
JObj.AddPair(TJSONPair.Create('email', email.Text));
JObj.AddPair(TJSONPair.Create('password', password.Text));
RESTRequest1.AddBody(JObj);
RESTRequest1.Accept := 'application/json';
try
RESTRequest1.Execute;
except
On E: Exception do
....
end;
JObj.Free;
if RESTRequest1.Response.GetSimpleValue('session_token', sToken) then
begin
session.Text := sToken;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.