![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 2 of 2 total |
![]() |
Thu, Apr 16 2020 3:06 AM | Permanent Link |
Paul Coshott | Hi All,
I have finished writing my web application (in EWB of course). It uses an EWB Server with dll modules written in Delphi connecting to a Firebird backend. I now need to write a mobile companion app and decided to learn Flutter for that. It's all going quite well, but I'm having problems sending requests from Flutter to my EWB server services. I have been able to get it working by using only url parameters, but the Flutter app and the EWB web app will use the same services, so I'd like to get them both working with these services. In my web server services, I am able to read the RequestHeaders sent from Flutter, but not the RequestContent. In Flutter this is sent in the body parameter and this is sent as json. I'm not sure what the expected format of the RequestContent on the server side is? The values in the Flutter variable body do come through into the RequestContent on the server, but it's not formatted so it can be read properly. My EWB app sends a request like: with srvReq_Login do begin Method := rmPost; URL := '/modules/rmo_daMLogin'; RequestHeaders.Clear; RequestHeaders.Values['Content-Type'] := 'text/plain'; RequestContent.Clear; RequestContent.Values['rmoService'] := 'User_Login'; RequestContent.Values['UserId'] := eUserID.Text; RequestContent.Values['Password'] := ePassword.Text; Execute; end; My Flutter code looks like this: Future<Staff> fetchStaff() async { String body = jsonEncode( {'rmoService': 'User_Login', 'UserId': 'fred', 'Password': 'abc123'}); final response = await http.post( Uri.encodeFull( 'http://mobileuser.pvapps.one:82/modules/rmo_daMLogin'), headers: {'Content-Type': 'text/plain'}, body: body); if (response.statusCode == 200) { // If the server did return a 200 OK response, then parse the JSON. return Staff.fromJson(json.decode(response.body)); } else { // If the server did not return a 200 OK response, then throw an exception. throw Exception('User or Password was incorrect.'); } } Has anyone worked with Flutter and an EWB server? Any ideas what I need to do to get this working? Hope everyone is staying safe and healthy. Cheers, Paul |
Thu, Apr 16 2020 6:44 PM | Permanent Link |
Paul Coshott | Hi All,
For anyone in the future who may be interested, I got it working. Instead of sending the body (RequestContent) encoded as json, I sent it as plain text with a line break between each key pair. Cheers, Paul Flutter code: Future<Staff> fetchStaff(String pUserName, String pPassword) async { final response = await http.post( Uri.encodeFull('http://mobileuser.pvapps.one:82/modules/rmo_daMLogin'), headers: {'Content-Type': 'text/plain'}, body: 'rmoService=User_Login\n' 'UserId=$pUserName\n' 'Password=$pPassword'); if (response.statusCode == 200) { // If the server did return a 200 OK response,then parse the JSON. return Staff.fromJson(json.decode(response.body)); } else { // If the server did not return a 200 OK response, then throw an exception. throw Exception('User or Password was incorrect.'); } } |
This web page was last updated on Sunday, April 27, 2025 at 01:25 AM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |