Last post Apr 02, 2019 08:09 AM by PatriceSc
Apr 01, 2019 03:24 PM|joanneraye|LINK
I have an Xamarin app in Beta testing. In the production environment it connects to a WCF service with a poorly-written back-end. I am now writing a Core API for a new back-end (for the app and other new clients I will write). I would like to test my
Web API using my Xamarin app in a development environment (VS 2017). My Core API works with Postman, but how do I host my API on my development box in such a way that my Xamarin app can consume it? In my research I have found info on consuming a web api
from Xamarin which would allow me to test my Xamarin app on a deployed Web API. But I don't know how to consume the API that I wrote myself and is still in development.
Apr 01, 2019 03:44 PM|bruce (sqlwork.com)|LINK
I don't use Xamarin, but with my mobile apps I typically run the emulator on a box with access to the test site (if its not the same box). Just set the url to the test url. If the test site is on the local wifi network, you can connect over wifi to the
test site from a physical device.
Apr 01, 2019 04:18 PM|PatriceSc|LINK
If I remember you have to use http://10.0.2.2:5000 so that the Android emulator goes back to the host machine (and if I remember I had to change the emulator proxy settings but it likely depends on what your company uses
as a default).
If you need further help ask rather in a Xamarin forum (and be more specific about the exact configuration you are targetting ie you want to test both the Xamarin app and your API on your own development machine ?)
Apr 01, 2019 06:25 PM|joanneraye|LINK
Thanks for the response. I don't understand it but I appreciate it . :) As far as Xamarin forums go, I will try that also. Thanks.
Apr 01, 2019 06:28 PM|joanneraye|LINK
Thanks for the response. Everything is on the same box. But neither localhost or the actual IP address works. My Xamarin app can't find the Web API. I have a feeling it has something to do with my IIS setup? I don't know much about IIS though so I
am going to take an online class on it and see if that helps. Thanks again.
Apr 01, 2019 07:49 PM|bruce (sqlwork.com)|LINK
localhost won't work, because that would be the android device itself. the ipaddress should work. it likely that port 5000 is not open via the firewall. either have IIS host the site, of if you are not using IIS, use port 80 instead of 5000.
if you want to use 5000, just add a firewall rule to open port 5000.
Apr 02, 2019 07:42 AM|Sherry Chen|LINK
Hi joanneraye ,
Not familiar with Xamarin , refer to the following links on the similar issue which may be helpful
Best Regards ,
Apr 02, 2019 08:09 AM|PatriceSc|LINK
I meant based on https://developer.android.com/studio/run/emulator-networking :
- have your web service running in a VS instance
- run your Xamarin app in another instance and have your code hit the service at 10.0.2.2 which should be mapped to the machine that runs the emulator allowing to hit your web service
If I remember I also had to use the emulator menu and change proxy settings (but it likely depends on which proxy settings are in use on your development machine).