Tema: post a web
Ver Mensaje Individual
  #27  
Antiguo 17-05-2023
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.285
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Tal vez me he perdido algo, pero sigo echando en falta que pruebes a cargar el fichero en el Body.
Con este código:

Código Delphi [-]
    
//RQFile.ClearBody;     
RQFile.Method := TRESTRequestMethod.rmPOST;      
_file := TMemoryStream.Create();     
_file.LoadFromFile(localfile);     
_file.Position := 0;       
param := RQFile.Params.AddItem;     
RQFile.Params[0].name := 'archivo';     
RQFile.Params[0].value := MemoryStreamToString(_file);

Creo que lo estás intentando cargar como parámetro.
Intenta cargarlo en el Body con esto:

Código Delphi [-]
var
  Contenido: TStringStream;
begin
  ...
  //RQFile.ClearBody;  
  RQFile.Method := TRESTRequestMethod.rmPOST;
  // Creamos el stream
  Contenido := TStringStream.Create;
  try
    // Cargamos el cntenido del fichero en el TStream
    Contenido.LoadFromFile('Fichero.xml');   // aquí tu fichero   
    // Añadirlo al Body
    RQFile.Body.Add(Contenido, TRESTContentType.ctTEXT_PLAIN);  
    //  => Prueba a cambiar el segundo porámetro por diferentes tipos según lo que estás enviando

    // ejecutar la peticion
    RQFile.Execute;
    jValue := RRFile.JSONValue;     
    Memo2.Text := jValue.ToString  
  finally
    contenido.Free;
...
  end;

Está claro que si en el PostMan te está funcionando en el Body, aquí debes usar la propiedad Body para enviarlo.
https://docwiki.embarcadero.com/Libr...STRequest.Body
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.

Última edición por Neftali [Germán.Estévez] fecha: 17-05-2023 a las 17:50:24.
Responder Con Cita