UniDAC + XData get CoInitialize problem

Hi there

I'm not sure how many people using UniDAC with XData. I'm trying to follow a video on TMS channel and trying to connect XData with SQL Server's Northwind DB.
  • Delphi Community 10.3.2, Also tested on Delphi 10.2.3 Enterprise. Same result
  • UniDAC Demo 8.0.1
  • SQL Server Express 2016 with Windows Authentication, open TCP/IP connection and port 1433
I can connect to database with UniConnection properly.
I can get the list of model classes via http://localhost:2001/tms/xdata
but I cannot get the data in each classes like http://localhost:2001/tms/xdata/customers

Sorry for the images didn't show above.

Check the shared folder here https://www.dropbox.com/sh/p6m96kah7f3wgal/AABDgggvxhT1lx2Y3DT3sCOQa?dl=0

Hi, from your project, it looks like you are mixing two ways of creating a XData Server. You are using the legacy approach (where you have the TXDAtaServerModule being created manually from code) and then you dropped a TXDataServer component. The TXDataServer component you dropped is not being used, thus the code you added to its event is also not being used.

I'd suggest you create a new application using the "TMS XData VCL Server" wizard. That will properly setup the components in the way you need. It's actually much simpler than your code.
If you want to fix your existing code, then you should remove the TXDataServer component and add the middleware code to your TXDataServerModule directly in code, inside the StartServer procedure declared in unit Server:

  Module := TXDataServerModule.Create('http://+:2001/tms/xdata',

    procedure(Context: THttpServerContext; Next: THttpServerProc)
      CoInitializeEx(nil, COINIT_MULTITHREADED);