I created a simple test project to call a REST WebService with TMSCore (Trial Version!), code see attachment. for test purpose i call the "Hello" resource of the WebService, that returns a simple text without Authentication needed. If i call the resource with PostMan it works perfectly. The URL is 'https://wsrest.sabes.it/amm/pagopa/hello', reacheable only internally
My code seems to be ok... if, for example, I call the URL 'TMS Software | Blog' (TMS software blog) everything works perfectly and i get the HTML of the Web page as a Response, displayed in the TWebMemo component.
But if I call my local REST WebService or other Websites as for example 'https://www.google.de/' I always get this error:
ERROR
Uncaught [object Object] | FMessage::HTTP request error @https://wsrest.sabes.it/amm/pagopa/hello FHelpContext::0 FJSError::Error: HTTP request error @https://wsrest.sabes.it/amm/pagopa/hello FStack::Error: HTTP request error @https://wsrest.sabes.it/amm/pagopa/hello at Object.Create$1 (http://localhost:8000/TMSWebCoreTEST/TMSWebCoreTEST.js:3432:23) at Object.c.$create (http://localhost:8000/TMSWebCoreTEST/TMSWebCoreTEST.js:337:19) at Object.HandleError (http://localhost:8000/TMSWebCoreTEST/TMSWebCoreTEST.js:29804:50) at XMLHttpRequest.cb (http://localhost:8000/TMSWebCoreTEST/TMSWebCoreTEST.js:261:28)
at http://localhost:8000/TMSWebCoreTEST/TMSWebCoreTEST.js [263:50]
thank you in advance for your help!
my code:
type
TForm1 = class(TWebForm)
WebButton1: TWebButton;
wmResponseContent: TWebMemo;
WebHttpRequest1: TWebHttpRequest;
procedure WebButton1Click(Sender: TObject);
procedure WebHttpRequest2Error(Sender: TObject;
ARequest: TJSXMLHttpRequestRecord; Event: TJSEventRecord;
var Handled: Boolean);
private
[async] procedure CallWS;
public
[async] function GetResultAsString: TJSPromise;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.CallWS;
var
LResultString: String;
LResult: TJSXMLHttpRequest;
begin
WebButton1.Caption := 'Loading...';
WebHttpRequest1.URL := 'https://wsrest.sabes.it/amm/pagopa/hello';
LResult := await(TJSXMLHttpRequest, WebHttpRequest1.Perform);
LResultString := LResult.responseText;
wmResponseContent.Lines.Text := LResultString;
end;
procedure TForm1.WebButton1Click(Sender: TObject);
begin
CallWS;
end;