Here is the complete code, in case you ever have that "philanthropic" moment.
The interface consists of an edit button to show the result and two buttons, one for local access and another to access the same application in the cloud (this one has an SSL problem, which is in another topic on this forum).
The application is an AWS lambda, developed in Python, running locally using the Serverless Framework. I even thought that this could be the problem, but it works normally via Postman.
As you said, it is really frustrating.
To avoid being stuck indefinitely, since I already have the entire backend built, I decided to download Delphi Community. It took me a while to find the correct syntax for TRESTClient, but everything worked well, locally and in the cloud. That gives me a year to try to solve it in FPC.
Cheers.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, fphttpclient, fpjson, opensslsockets;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
Function Send(Url : String) : String;
Var Client: TFPHttpClient;
Response: TStringStream;
Begin
Client := TFPHttpClient.Create(nil);
Client.ConnectTimeout := 6000;
Client.AddHeader('Content-Type', 'application/json');
Client.AddHeader('Accept', 'application/json');
Client.RequestBody := TRawByteStringStream.Create('{"jwt": "", "codAplicacao": "F60EB930-9B1B-11EF-9657-02240D86274B"}');
Response := TStringStream.Create('');
Try
Try
Client.Post(Url, Response);
Result := 'Response: ' + Response.DataString;
Except on E: Exception do
Begin
Result := 'Something wrong: ' + E.Message;
End;
End;
Finally
Client.RequestBody.Free;
Client.Free;
Response.Free;
End;
End;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text := Send('https://mystack.execute-api.us-east-2.amazonaws.com/dev/inicio/hortech');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text := Send('http://localhost:4000/local/inicio/hortech');
end;
end.