Ver Mensaje Individual
  #3  
Antiguo 09-04-2021
balger balger is offline
Miembro
 
Registrado: may 2011
Posts: 30
Reputación: 0
balger Va por buen camino
Gracias por responder. Por suerte pude resolver el tema.
La cosa esquemática es así

Código Delphi [-]
types
  Clase1 = Class
     RESTClient1: TRESTClient;
     RESTRequest1: TRESTRequest;
     RESTResponse1: TRESTResponse;
     OAuth2Authenticator1: TOAuth2Authenticator;

 private
    procedure ReqsSetBody;

  public 
     procedure create
     procedure destroy 
end

procedure create
  RESTClient1 := TRESTClient.Create(nil);
  RESTRequest1 := TRESTRequest.Create(nil);
  RESTResponse1 := TRESTResponse.Create(nil);
  OAuth2Authenticator1 := TOAuth2Authenticator.Create(nil);
end

procedure destroy
  FreeAndNil(OAuth2Authenticator1);
  FreeAndNil(RESTRequest1);
  FreeAndNil(RESTResponse1);
  FreeAndNil(RESTClient1);
end

procedure ReqsSetBody
var  
  jsnBody: TJSONObject;

begin
  jsnBody := TJSONObject.Create;
  try
    jsnBody.AddPair(lowercase(f.FieldName), VarToStr(Trim(f.Value1)));
    jsnBody.AddPair(lowercase(f.FieldName), TJSonNumber.Create(f.Value2));
    jsnBody.AddPair(lowercase(f.FieldName), DateToISO8601(f.Value3, True));

    RESTRequest1.AddBody(jsnBody);
    
  finally
    jsnBody.Free;
 end;

end;

El problema fue resuelto cambiando la visibilidad de (y todo lo que involucra)
var jsnBody: TJSONObject en procedure ReqsSetBody

a la sección privada de la clase y agregando su creacion a procedure create.

Desconozco si existe una mejor opción.
Responder Con Cita