Calling REST Api from within Unity - Android runtime error

Hi,

I’m evaluating migrating an turnbased Android game from Android Studio to Unity. The game calls a REST API on a backend server (Google AppEngine, JSON encoded HTTP requests) so I need to be able to call the backend from within Unity.
As a proof of concept, I am generating a C# client-side API using https://swagger.io/ and testing it against swagger’s “petstore” testserver. The code generated from swagger has a dependency towards two other components (Newtonsoft and Restsharp). I have successfully built the clientside dll from the code generated by swagger and imported the resulting dll plus the Newtonsoft and Restsharp dlls into Unity. I had to change the Scripting Runtime Version in Unity to “Experimental (.NET 4.6 Equivalent)” in order to be compatible with the C# client side API I built.
When building for Windows platform everything seems to work when I run the application. I can call the petstore REST API. But on Android, I get a very uninformative runtime error (“error calling xxxxx: getdomainname”).
A few questions:

  1. Should it be possible at all to deploy on Android even though I have imported external dll’s as described above? I’m not very familiar with the .NET runtime environment and dll concepts.
  2. Has anyone generated client side API’s for REST backend API with some other tools? I really need a client side wrapper since my client-server communication uses rather complex data structures and I do not want to manually encode/decode the JSON data.

I’ve been working on Unity friendly OpenAPI parser and assets generator GitHub - kolodi/UnityOpenApi: Unity friendly RESTful API client generator for some time, it resolves all issues with the multi-platform support and leverage many Unity-specific tools to provide an easiest possible way to work with the restful API.
It is not finished yet, and I’m working on it now, your contribution is welcomed :slight_smile: