'Error when accesing binance API with Delphi

I am trying to do a small application (hello world for start) for accesing binance API with Delphi 10.3 using TRESTClient.
Here is the code:

procedure TfrmMain.btnInfoClick(Sender: TObject);
var workStream     : TStringStream;
    workResponse   : TStringStream;
    responseObject : ISuperObject;
    serverTIME     : Int64;
begin
  mDEBUG.Lines.Clear;
  try
    workStream   := TStringStream.Create;
    workResponse := TStringStream.Create;

    restCLIENT_MAIN.ResetToDefaults;
    restREQUEST_MAIN.ResetToDefaults;
    restRESPONSE_MAIN.ResetToDefaults;
    restCLIENT_MAIN.BaseURL := API_URL;
    serverTIME              := GetAPI_TIME;
    restREQUEST_MAIN.Resource       := '/sapi/v1/broker/info';
    restREQUEST_MAIN.ResourceSuffix := 'timestamp=' + serverTIME.ToString + '&signature=' + SECRET_KEY;
    restREQUEST_MAIN.Method         := TRESTRequestMethod.rmGET;
    restREQUEST_MAIN.AddParameter('Content-Type', 'application/json');
    restREQUEST_MAIN.AddParameter('X-MBX-APIKEY', CLIENT_KEY);
    restREQUEST_MAIN.Execute;
    workResponse   := TStringStream.Create(restRESPONSE_MAIN.JSONText);
    responseObject := TSuperObject.ParseStream(workResponse, True);
    if responseObject <> nil then begin
      mDEBUG.Lines.Add(responseObject.AsString);
    end else begin
      mDEBUG.Lines.Add(restRESPONSE_MAIN.Content);
    end;
  finally
    mDEBUG.Lines.Add('');
    mDEBUG.Lines.Add('restCLIENT_MAIN.BaseURL:' + restCLIENT_MAIN.BaseURL);
    mDEBUG.Lines.Add('restREQUEST_MAIN.Resource:' + restREQUEST_MAIN.Resource);
    mDEBUG.Lines.Add('restREQUEST_MAIN.ResourceSuffix:' + restREQUEST_MAIN.ResourceSuffix);
    FreeAndNil(workStream);
    FreeAndNil(workResponse);
  end;
end;

The result is:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Apr 01 17:32:16 UTC 2021There was an unexpected error (type=Not Found, status=404).No message available
restCLIENT_MAIN.BaseURL:https://api.binance.com/
restREQUEST_MAIN.Resource:sapi/v1/broker/info
restREQUEST_MAIN.ResourceSuffix:timestamp=1617298336054&signature=<SECRET_KEY>

However form POSTMAN the result is different: Because I cannot send the correct time (less than 1 second window of opportunity) I suspect that potman will always give me this kind of error.

{
    "code": -1021,
    "msg": "Timestamp for this request is outside of the recvWindow."
}

anyone can guide me?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source