Search code examples
restdelphihubspotdelphi-xe8

Delpi XE8 REST Client and HubSpot


I am trying to use Delphi XE8 RESTClient,RESTRequest and RESTResponse to optain the content of the response to the following API call:

https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=Demo&count=1000

The call runs fine in C# and in a webbrowser.

I'm not sure how to configure RESTClient and RESTRequest properties.

Can anyone breakdown the API call into RESTClient & RESTRequest properties for me?

I've been wrestling with this for hours and no success so far.


Solution

  • Below is a simple example of the assignment of properties for the REST components.

    Creating a new project and dropping a Button, RESTClient, RESTRequest, RESTResponse, and Memo on the form - you can use the code below on your Button Click event to see it work.

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      RESTRequest1.Client := RESTClient1;
      RESTRequest1.Response := RESTResponse1;
    
      RESTClient1.BaseURL := 'https://api.hubapi.com';
    
      RESTRequest1.Resource :=
        'contacts/v1/lists/all/contacts/all?hapikey=Demo&count=1000';
    
      RESTRequest1.Execute;
    
      Memo1.Text := RESTResponse1.Content;
    end;