This is wrong:
dm_apitest.DataMod.SemClient.Request.Agent := 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.78 Safari/532.5';
It should be ...
dm_apitest.DataMod.Sem
Request.Request.Agent := 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.78 Safari/532.5';
This makes absolutely no sense:
dm_apitest.DataMod.SemRequest.Request.Info.Obj['DMForm']:=dm_apitest.DataMod;
MyDM:=TDataMod(DataMod.SemRequest.Request.Info.Obj['DMForm']);
What I meant is that you could store the FORM object inside "Request.Info.Obj[]", so it can be accessed from TRtcDataRequest events, even if the TRtcDataRequest component is NOT placed on the Form. But looking at your code now, that wasn't your goal.
About your question ...
1) I understand that the datarequest (SemRequest) has an event call BeginRequest. and
2) there is a property called TRtcConnection and another property TRTCDataClient to write the header ..... but how are these two accessible from the main form?
Read, Write and WriteHeader methods should ONLY be used from the context of RTC events (triggered on components responsible for request/response processing). Would you want to use Read, Write or WriteHeader methods from any other procedure or method, you would need to call that other procedure or method from inside RTC events responsible for request/response processing (like OnBeginRequest, OnDataReceived, OnDataSent).
I am thinking that putting the clients on the datamodules is far more trouble than it is worth.
Putting "clients" (TRtcHttpClient component) on the DataModule is NOT a problem. But, you are trying to put a TRtcDataRequest component on a DataModule, even though you want to keep the control of that component on the Form. And that is (obviously) not worth the trouble.
The only thing you could do, is place the TRtcHttpClient component ("SemClient" in your case) on the Main Form or the main DataModule, so it will be created before anything else, and made accessible to all the other components which need it (TRtcDataRequest and TRtcClientModule).
As for the TRtcDataRequest components... because you can have as many TRtcDataRequest components as you want, even if all of them will be using a single TRtcHttpClient component, there is no reason for placing a TRtcDataRequest component on a DataModule when you ONLY want to use it from a Form.
To make a long story short, keep it simple. And in your case, it means keeping the TRtcDataRequest component on the Form. If you need to process requests on other Forms or DataModules, just drop a new TRtcDataRequest component there and link its "Client" property to your main TRtcHttpClient component.
Best Regards,
Danijel Tkalcec