Skip to content

Instantly share code, notes, and snippets.

@philicious
Last active June 2, 2016 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philicious/87e40356291825977f8dbb08bcc8b1fc to your computer and use it in GitHub Desktop.
Save philicious/87e40356291825977f8dbb08bcc8b1fc to your computer and use it in GitHub Desktop.
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