How to obtain the user's IP address

I know, this question has been asked before. Unfortunately, I didn't understand the answer(s). I would like to know my user's IP address for logging (via XData server) and for providing IP address specific functionality.
Please explain how.
Thanks Chris

Hi there...

Probably a number of ways to tackle this. What I've done on the XData Server side is just pickup the client IP address within a service ednpoint call. Eg:

TMyService.GetClientIP(ClientName: String):String;
  Result := TXDataOperationContext.Current.Request.RemoteIP;
  SomeLoggingFunction(ClientName, Result);

You pass it some kind of client identifier (for example) and then you can log it in whatever way suits you along with the IP address that it is related to. The usual caveats apply of course about using IP addresses for anything too serious due to the prevalence of VPNs and the like.

Thanks Andrew for your quick reply! I actually meant something like this:

procedure TForm1.WebHttpRequestResponse(Sender: TObject; AResponse: string);

procedure TForm1.GetMyIP;
 with WebHttpRequest1 do begin
   URL := '';
   Command      := httpGET;
   ResponseType := rtText;
   OnResponse := WebHttpRequestResponse;
   Headers.Text := '';
end ;

which gives me this: :grinning:

{"ip":"2a0a:a541:9951:0:9b8:3b65:fe82:48e5","continent_code":"EU","country":"Germany","country_code":"DE","country_code3":"DEU","latitude":51.0000,"longitude":9.0000,"timezone":"Europe\/Berlin","offset":3600,"asn":8422,"organization":"NetCologne Gesellschaft fur Telekommunikation mbH"}

This should work for me right now.

Ah! That's a slightly different question :thinking: Glad you got what you were after.