Search the Community
Showing results for tags 'rest'.
Found 2 results
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
In addition to Delphi and FreePascal clients, our framework is now able to access any mORMot server from HTML5 / AJAX rich client, thanks to Smart Mobile Studio. Take a look at this series of blog articles: Units and platforms; Generating the client code wrappers; Delphi / FreePascal clients; Smart Mobile Studio clients. There is no package to be installed within the Smart Mobile Studio IDE. The client units will be generated directly from the mORMot server. Any edition of Smart is enough: you do not need to pay for the Enterprise edition to consume mORMot services. But of course, the Professionnal edition is recommended, since the Basic edition does not allow to create forms from the IDE, which is the main point for an AJAX application. In contrast to the wrappers available in the Enterprise edition of Smart, for accessing RemObjects or DataSnap servers, our mORMot clients are 100% written in the SmartPascal dialect. There is no need to link an external .js library to your executable, and you will benefit of the obfuscation and smart linking features of the Smart compiler. A set of object pascal units will provide a solid and shared ground for the any kind of clients: Connection to a mORMot server via HTTP, with full REST support; Support of weak or default authentication to secure the transfer - see Authentication; Definition of the TSQLRecord class, using RTTI when available on Delphi orFreePascal, and generated code for Smart Mobile Studio; Remote CRUD operations, via JSON and REST, with a TSQLRestClientURI class, with the same methods as with the mORMot.pas framework unit; Optimized TSQLTableJSON class to handle a JSON result table, as returned bymORMot's REST server ORM - see JSON (not) expanded layouts; Batch process - see BATCH sequences for adding/updating/deleting records - for transactional and high-speed writes; Client-Server services via methods with parameters marshaling; Client-Server services via interfaces with parameters marshaling and instance-life time; Mapping of most supported field types, including e.g. ISO 8601 date/time encoding, BLOBs and TModTime/TCreateTime; Complex record types are also exported and consumed via JSON, on all platforms (for both ORM and SOA methods); Some cross-platform low-level functions and types definitions, to help share as much code as possible between your projects. Hope you find it interesting! Smart Mobile Studio rocks!