Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread ServerRequest returns access denied
Fri, Dec 2 2022 6:23 PMPermanent Link

Jose Verger

Cybernav

Avatar

I am making a REST communication to an URL  http://www.cibertracs.com:8081/REP  sending a simple message and it will respond , but jumps to an exception with the message Access Denied when calling the ServerRequest.Execute method,  what is needed to make it work ?

try
 ServerRequest1.Method:=rmPut;
 ServerRequest1.URL:='http://www.cibertracs.com:8081/REP';
 ServerRequest1.Content.Clear;
 ServerRequest1.Content.Add('TEST');
 ServerRequest1.Headers.Clear;
 ServerRequest1.Headers.Add('Content-Type: text/xml');
 ServerRequest1.Headers.Add('Content-Length:'+IntToStr(length(ServerRequest1.Content.Text)));
 ServerRequest1.Execute;
except
 on E:Exception do
  begin
   LogOutput('xErr '+E.Message);
  end;
end;

regards
Fri, Dec 2 2022 7:49 PMPermanent Link

erickengelke

Avatar

Jose Verger wrote:

> I am making a REST communication to an URL  http://www.cibertracs.com:8081/REP  sending a simple message and it will respond , but jumps to an exception with the message Access Denied when calling the ServerRequest.Execute method,  what is needed to make it work ?

Hi, this can be the result of CORS which is a security thing you can Google.

Try enabling the debugging console in Chrome or Firefox then access your application.  Look at the "console" section for CORS errors, or in the Network traffic section.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Fri, Dec 2 2022 7:49 PMPermanent Link

erickengelke

Avatar

Jose Verger wrote:

> I am making a REST communication to an URL  http://www.cibertracs.com:8081/REP  sending a simple message and it will respond , but jumps to an exception with the message Access Denied when calling the ServerRequest.Execute method,  what is needed to make it work ?

Hi, this can be the result of CORS which is a security thing you can Google.

Try enabling the debugging console in Chrome or Firefox then access your application.  Look at the "console" section for CORS errors, or in the Network traffic section.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Fri, Dec 9 2022 4:32 PMPermanent Link

Jose Verger

Cybernav

Avatar

Very useful your reply, thanks Erick
Image