difference between Rest Debugger and TMS Webcore ?

Hi , 


I have used both Delphi Rest Debugger and TMS Webcore WebHttpRequest to test with my 
backend server but can i find out why it acted differently and i could not get the same result ,

In my rest debugger , i have added :
method : Get 
url : http//172.16.244.1:8069/api/user
request header parameter , i have added the 2 headers param below ,
access-token=mytoken_123 ,
content-type=application/x-www-form-urlencoded

and i got ALL my expected result ,
1. my python backend server , i set the debugger for a break point and it works.
2. the result responded also correct ,


But in my TMS Webcore , i used TWebHttpRequest component ,
i set it in my delphi code as follow ,

   self.RestRequestConn.Headers.Clear;
   self.RestRequestConn.Headers.Add('content-type=application/x-www-form-urlencoded');
   self.OdooRestRequestConn.Headers.Add('access-token=mytoken_123');
   self.OdooRestRequestConn.Command := httpGET;

1. i expecting the python backend server breakpoint will work too , but it didn't
    so my answer to it is that , because my TMS webcore application is running in it's 
     web server which did not trigger the break point in my python backend server ,
     is that correct ?

2. the python backend log file responded with the detail as follow TMS Webcore application,
    werkzeug: 172.16.244.189 - - [04/Feb/2019 03:07:35] "OPTIONS /api/res.users HTTP/1.1" 405
    
    which it is different from the one called by Delphi REST Debugger ,
   werkzeug: 172.16.244.189 - - [04/Feb/2019 03:11:56] "GET /api/res.users HTTP/1.1" 200 -

   as i noticed the response with "OPTIONS" instead of "GET" , why it did not get the GET keywords,
   so i suspect the TWebHTTPRequest , is not working and are not sending even the 
   HTTP command correctly or is there anything i have done wrong ?






for the python server , the respond with Delphi rest debugger are :

https://snag.gy/32JxvW.jpg

but for the TMS Webcore . i check on the headers passed , but
none that my backend is expected is there ,
here is the image that show us that the headers is different from Delphi Rest Debugger.
https://snag.gy/WguUhC.jpg

please advice , as we cannot even pass custom headers into requests
and are unable to connect to my backend properly ,when we trying to set
some security param in our http headers. Please advice.

 thanks.




i have further tested that both TWebHttpRequest and TWebClientConnection component,

no matter what HTTP command i used , my backend server will receive it as
"OPTIONS" after i submit my request  , only TWebClientConnection , which the only available option
is "GET" , that some how it works but not fully as expected .

i have confirmed it by changing my back-end server to allow , my endpoint to temporary
accept HTTP command "OPTIONS" , and then my backend code worked again.

so can i confirm whether the HTTP command when it send to backend it has some issues ,
even if i set the properties to httpGET, httpPOST , it will always receive as OPTIONS ?

Did you enable CORS on this python server?

https://stackoverflow.com/questions/50065875/how-to-enable-cors-in-python

yes, i did enable the CORS, but is that related and will that help in 2 my issues here ,


1. the headers access_token cannot be sent in TMS webcore but in Rest debugger it has
    no issues , how can i correctly send my custom header , http_access_token ?

2. why the response i got in my backend server is different  when i compare delphi rest debugger and TMS webcore , i.e. one is responded with OPTIONS as http method and another is correctly responded with GET or POST method ?

this is important and critical to my development, as currently i am stuck here, please advice .
Thanks.

The OPTIONS request is an expected part in a CORS request

https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request

So, please make first sure that CORS is properly enabled on your server.