Last active
June 2, 2016 10:39
-
-
Save philicious/87e40356291825977f8dbb08bcc8b1fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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