Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Colaboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #14  
Antiguo 30-03-2026
andressanchez andressanchez is offline
Miembro
 
Registrado: jul 2005
Ubicación: Sando Domingo, Rep. Dom.
Posts: 119
Poder: 21
andressanchez Va por buen camino
¡Hola!

Todo funciona correctamente con la implementacion de HTTPS POST.

Código Delphi [-]
procedure EnviarECF(FacturaJSON:string);
var
  IdHTTP: TIdHTTP;
  RequestBody: TStringStream;
  ResponseBody: string;
  JsonString: string;
  URL: string;
  // If using HTTPS, an IOHandler is needed
  LHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
  URL := 'https://example.com/api/endpoint';
  IdHTTP := TIdHTTP.Create(nil);
  RequestBody := TStringStream.Create('');

  try
      // *** If the URL is HTTPS, create and assign the SSL IOHandler ***
      try
        LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
        LHandler.SSLOptions.Method := sslvTLSv1_2;
        LHandler.SSLOptions.SSLVersions := [sslvTLSv1_2];
        IdHTTP.IOHandler := LHandler;
        // Configure SSL options if necessary (TLS version, etc.)

        JsonString := FacturaJSON; // Your JSON data

        IdHTTP.Request.Accept := 'application/json';
        IdHTTP.Request.ContentType := 'application/json'; // Set content type

        // Write JSON string to the stream
        RequestBody.WriteString(JsonString);
        RequestBody.Position := 0; // Reset stream position to the beginning

        // Perform the POST request
        ResponseBody := IdHTTP.Post(URL, RequestBody);

        // Process the response 
        ShowMessage('Response: ' + ResponseBody);

    except
      on E: EIdHTTPProtocolException do
        ShowMessage('HTTP Error: ' + E.Message + ' ' + E.ErrorMessage);
      on E: Exception do
        ShowMessage('Error: ' + E.Message);
    end;
  finally
    // Free objects
    FreeAndNil(RequestBody);
    FreeAndNil(IdHTTP);
    // IOHandler is freed with IdHTTP if it is the owner
  end;

end;

Así consumimos el procedure anterior desde un formulario. Memo1 contiene el JSON.

Código Delphi [-]

procedure TFeCFEnvio.btEnviarClick(Sender: TObject);
begin

EnviarECF(Memo1.Lines.Text);

end;

Seguimos evaluando proveedores.

Nuevamente muchas gracias!
Saludos.-
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
enviar objeto con delphi xe8 a restful con php jgutti PHP 0 10-07-2017 18:29:31


La franja horaria es GMT +2. Ahora son las 03:07:01.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi