C
C#8mo ago
Raulino

✅ How can I connect my Xamarin app to my local API?

I have an API running in my machine and for test purposes I only need it to be local.
33 Replies
Raulino
RaulinoOP8mo ago
It doesn't work with localhost, nor with my IpAdress Calling it in my own machine also doesnt work if I change the Ip from localhost to My IP
leowest
leowest8mo ago
I don't know about Xamarin but in MAUI you have to do some overly annoying things to get localhost working let me see if I can find hte thread https://discord.com/channels/143867839282020352/1221703280204451932/1221830944231657603 see if its something related to this if not just ignore me 😉 or the simplest u just disable https in the api
Raulino
RaulinoOP8mo ago
Turned https off... the problem remains, and as well, even in postman in my own machine I cannot call my own IpAdress
leowest
leowest8mo ago
postman doesnt let u call localhost?
Raulino
RaulinoOP8mo ago
This is so weird, I dont remember changing my config on these terms localhost yes, but when I place my raw IP it ignores
leowest
leowest8mo ago
well u just need localhost from xamarin as well but what is the other ip ur trying to use? 192...? 127...? or real external ip
Raulino
RaulinoOP8mo ago
No description
Raulino
RaulinoOP8mo ago
I tried 192, 127 i tried typing random numbers to see if I fool the xamarin app I will try again with http tho
leowest
leowest8mo ago
u have to add permissions to the manifest
Raulino
RaulinoOP8mo ago
Not permitted. am I missing some file configuration here
No description
Raulino
RaulinoOP8mo ago
Its a test for a vacancy... nothing will go public
leowest
leowest8mo ago
I mean the code is simple enough so why not anyway did it work?
Raulino
RaulinoOP8mo ago
nope
leowest
leowest8mo ago
from the link above?
Raulino
RaulinoOP8mo ago
I have my phone connected via USB, I dont know if makes any difference
leowest
leowest8mo ago
ah ok you're not using the emulator u would have to acccess it via the network ip it gives your phone then check the network details
Raulino
RaulinoOP8mo ago
I tested with the IPV4 this is the one you reffering to?
leowest
leowest8mo ago
I mean u can just go to the mobile configuration and check yes ipv4
leowest
leowest8mo ago
No description
leowest
leowest8mo ago
that page would tell u so if it is 192 something then u would use your local 192 to access it then u would have to add it to your api which is probably only listening to localhost
Poller
Poller8mo ago
for such scenarios MS created the dev tunnels that are easy accessable in visual studio.
leowest
leowest8mo ago
ah true that is also an option forgot they added that but you can just add this line to your api's appsettings.Development.json as an alternative
"urls": "http://0.0.0.0:port"
"urls": "http://0.0.0.0:port"
change port to the port in your .http file then it will bind to localhost and other ips in your network card for the api
Raulino
RaulinoOP8mo ago
not even the f tunnels are working And to connect to this one in my Mobile I access 0.0.0.0? nothing worked 🙂 WORKED!!! I'm not aware of what I did, but it worked. Thanks a lot guys you're awesome tbh now, I removed the https and retried sending to my IPv4 and wroked 👍
leowest
leowest8mo ago
nice 😉 yeah 0.0.0.0 just means bind to all my available ips so imagine u have: 192.168.0.100 as your internal ip 127.0.0.1 as localhost 1x.xxx.xxx.xxx as your external ip it will try to bind to all of those on the pre-defined port 😉 so u would be able to access it on any of those by default it only binds to localhost which is why u were unable to access it before ------======= I strongly suggest thou, that u move to MAUI if u haven't develop too much of the app yet xamarin is pretty much dead and MAUI took its place
MODiX
MODiX8mo ago
Use the /close command to mark a forum thread as answered
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest8mo ago
do u think its worth it? its a lot of text
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest8mo ago
this was the second time ever and dev tunnels exists now so I am unsure this would be worth the trouble over just doing dev tunnels
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest8mo ago
thx for the suggestion thou I will look into writting something I been wanting to make a tag
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server