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.