Web Api access in Xamarin

Hi All,

I have created simple web api service and hosted in IIS, when trying to access get method through my xamarin app, it shows below exception.
there is any config changes in web api, xamarin app?

Web api:
[HttpGet("{name}")]
public City Get(string name)
{
try
{
return new City{};
}
catch (Exception)
{

            throw;
        }           
    }

url: http://localhost:6030/api/Weather/

Xamarin
Code:
HttpClient client = new HttpClient();
var response = await client.GetAsync(url);
if (response != null)
{
string json = response.Content.ReadAsStringAsync().Result;
}

Exception:
A connection with the server could not be established

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at System.Net.Http.WinHttpHandler.d__101.MoveNext()

Thanks,

Posts

Sign In or Register to comment.