Jump to content
Sign in to follow this  
Ricardo

Rest Api

Recommended Posts

Hi.

I'm trying TRestApi and I have a problem with external browsers

I have tried using TRESTApi.Post, the connection is established and works Ok using the internal browser: the server receives a POST and send me data. But if I use it from firefox or chorme, the server receives an OPTIONS (no GET, no POST) and gets into an infinite loop until I close the page. If this did not happen I could forget about the sockets, I think.

 

With Rest the code i use is:

try
    FRestAPI := REST[IP, URL].OnError(gestionError);

FRestAPI.Call
    .Header('Content-Type', 'application/json')
    .Header('Authorization',Token)
    .NoRandomize
    .OnDone( lambda(http) parsea(http.ResponseText); end )
    .Post(resultado);
    finally
       FRestApi.Free;
       end;

Usin external navegator, the server  receive this. No return data and enter on an infinite loop.

OPTIONS /api/myurl HTTP/1.1
Host: 192.168.1.170:8085
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: POST
Access-Control-Request-Headers: authorization,content-type
Origin: http://192.168.1.101:8090
Connection: keep-alive

 

usin internal navigator, the server  receive this

POST /api/ myurl HTTP/1.1
Host: 192.168.1.170:8085
Connection: keep-alive
Content-Length: 45
Accept: */*
Authorization: ;A2
Content-Type: application/json
Origin: http://192.168.1.101:8090
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
Referer: http://192.168.1.101:8090/index.html
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...