Jump to content
Registration disabled at the moment Read more... ×
TomEd

RESTRequest Body Property

Recommended Posts

I've prototyped a small app using the Delphi REST components.

function TForm1.QueryAPI(Resource: string): string;
begin
  RESTRequest1.Resource := Resource;
  RESTRequest1.Execute;
  Result := RESTResponse1.JSONValue.GetValue<string>('authorization');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  jValue:TJSONValue;
  AuthCode, AccessToken: string;
begin
  RestRequest1.AddBody('{"email":"<email>","password":"<password>"}', ctNone);
  AuthCode := QueryAPI('oauth/authorize');
  MemoContent.Lines.Add('auth = ' + AuthCode);
end;

<email> and <password> are obfuscated intentionally.

 

This all works fine when I omit the RestRequest1.AddBody and use the RestRequest1.Params property as Name = body (followed by 32 hex digits), Value = "email":"<email>","password":"<password>", and  Kind = pkRequestBody

in the IDE as provided by the REST Debugger.

 

I don't know the significance of the 32 hex digits following "body" in the Name field since it came over from the debugger.

 

Is this the proper way to add the body to RestRequest1 and what might be the significance of the hex digits following "body" (see attached; please excuse my clumsy editing)?

 

sp.jpg

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×