Unsupported URL iOS 64 iPhone 12.1

I have a FMX app that I am trying to run on an iPhone. The app loads and launches but when I try to login to a remote XData Server I get Connection Failed - Unsupported URL (Error - 1002). This isn't a problem when I run it under Win32. If I make a call to a service method which doesn't have any params that seems fine.

Any ideas?


  ILoginService = interface(IInvokable)
    function Login(const UserName, Password: string): string;

  IResourceSvc = interface(IInvokable)
    function TestThis: string;

procedure TDataModule1.DataModuleCreate(Sender: TObject);
  FClientAuth := TXDataClient.Create;
  FClientAuth.URI := remote_auth_uri;

  FClientRes := TXDataClient.Create;
  FClientRes.URI := remote_res_uri;

//This fails with Unsupported URL error -1002
function TDataModule1.Login(const UserName, Password: string): boolean;
   result := False;
   Token := FClientAuth.Service<ILoginService>.Login(UserName, Password);
   result := True;

//This is ok
function TDataModule1.TestRes: String;
  result := FClientRes.Service<IResourceSvc>.TestThis;

It should not be any difference in the URL because if that's the exact interface you are using client side, you have no [HttpGet] attribute in Login method, thus the parameters are simply passed in the body, not in the URL.

Usually errors in URL in iOS (sometimes Android as well) when the Windows version works are related to lack of percent encoding (which XData does automatically but it's not the case here) or some "security" issues, like using an IP as the host, using HTTP protocol instead of HTTPS, etc..
Your FClientRes and FClientAuth clients are accessing different URL's. What are the URL's used in each of them?
They both use the same root which is a domain named https call. The only difference is one ends /auth and the other /res both of which are handled within the same XData server.

It should work fine then. Are you able to create a minimal project (server and client) that reproduces the problem?

It seems that the way the exception was raised from the iOS install had me looking in the wrong place. It isn't on a call to the ILoginService that is the problem, that is working. 

I've now tracked this down to a TXDataClient.List call with a filter. As mentioned above, the whole thing works when I run it under Windows 32.

The request is 

XDataClient1.List<TAttendee>('$filter=(PersonId eq 2)');

This is fixed by encoding the spaces in the filter to "%20" (note encoding the spaces as "+" didn't work even though that is valid query encoding for a space) , as the querystring isn't encoded in TXDataClient. So 



Exactly. As mentioned, the url errors in iOS/Android are due lack of encoding or IP/non-https usage. To make it more generic, you can use this:

XDataClient1.List<TAttendee>('$filter=' + TSparkleUtils.PercentEncode('PersonId eq 2'));

That's exactly what I did :-) I just used the actual code for illustration.

Wouldn't it be better to encode the query in TXDataClient as is done for the Uri? Failing that I think it should be mentioned in xdata_manual.pdf

It's better to let user encode himself, because TXDataClient can never know if the string is already encoded or not.

1 Like