Jump to content
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×