Jump to content

GenoR

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. Sorry for resurrecting an old thread, but I too am looking to get the IP address of an Android device and will probably use your recommendation as a starting off point. However, perhaps in my case I do not need to get he IP address. In my scenario we have multiple locations throughout the state. I have an application that is on a device connected to a given location's WiFi and the manager logs into the device to process transactions. I can record "who" is processing the transactions, but I would also like to know "where" they are being processed. Each of our location networks follow a standard LAN configuration in which I can read on of the octets and know which network the device was on when the transaction was processed. I could do this based on various other device data, but these tablets are broken not infrequently, so a more reliable constant in my mind would be to know which of our networks it was on.
  2. I ended up just manually creating the JSONObject and adding pairs then adding that object to the body of the response. As long as my request isn't a very large JSON (and it shouldn't be) this is probably fine I'm thinking. procedure TfrmGCClient.btnAddTranClick(Sender: TObject); var JSONObj : TJSONObject; i: Integer; begin try jsonObj := TJSONObject.Create; jsonObj.AddPair('gcKey','66'); jsonObj.AddPair('TranDate','20221001'); jsonObj.AddPair('TranTime','15:22:08'); jsonObj.AddPair('TranLoc','120'); jsonObj.AddPair('TranType','1'); jsonObj.AddPair('TranAmt','50.00'); jsonObj.AddPair('UserID','GenoR'); bkEndEPAddTran.AddBody(jsonObj); bkEndEPAddTran.Execute; finally jsonObj.Free; jsonObj := nil; end; end;
  3. I may have found my own answer : bkEndEPAddTran.Body.JSONWriter After playing around the the TBackendEndpoint component more it occured to me that the Body might have a JSONWriter since it was of ARequest type and I know that the AResponse type's body had a JSONWriter. Going to play around with that. Somebody stop me if I'm going down the road of madness and there is a better way! Thank you in advance.
  4. I am new to REST development and have designed a simple Rad Server package with GET/POST and the like. I am using a BatchMover and a JSONWriter to fulfil the GET request, but am trying to figure out the best route to process a POST request sent by a client. I'm new to all of this and kind of self-teaching (with plenty of help online). In my client App I have a TBackendEndpoint object that I am adding parameters to and executing to trigger the post routine in my server module. Rather than receiving a JSON format I get my parameters concatenated together with &. I could just parse this out in my POST routine, but I am thinking I am doing this all wrong. I have a few questions : Am I using the right object to carry this out? (namely TBackendEndpoint) If so, how do I get this to send the Request in JSON format (don't I need to)? Here is the code from the Client side: //ADDING PARAMETERS TO A REQUEST AND EXECUTING IT bkEndEPAddTran.AddParameter('GCKEY','66'); bkEndEPAddTran.AddParameter('TRANDATE','20221001'); bkEndEPAddTran.AddParameter('TRANTIME','15:22:08'); bkEndEPAddTran.AddParameter('TRANLOC','120'); bkEndEPAddTran.AddParameter('TRANTYPE','1'); bkEndEPAddTran.AddParameter('TRANAMT','50.00'); bkEndEPAddTran.AddParameter('USERID','GenoR'); bkEndEPAddTran.Execute; And the code in the POST method of my Rad Server: //JUST LOOKING AT THE STRING REQUEST FROM THE CLIENT logStr := TStringlist.Create; logStr.Add(ARequest.Body.GetString); logStr.SaveToFile('postJSON'); The postJSON file contains : GCKEY=66&TRANDATE=20221001&TRANTIME=15%3A22%3A08&TRANLOC=120&TRANTYPE=1&TRANAMT=50.00&USERID=GenoR These are just snippets of the routine that is doing the work in question. Again, I could move forward parsing this result and creating my SQL insert with it, but I want to follow best-practices.
×