0

I wrote a Xamarin Forms application. It uses HttpClient. Code of my method is

 public static async Task<List<CarshareList>> SearchRidesAsync(string fromCity, string toCity, DateTime date, string type = "shares", CancellationToken token = default(CancellationToken))
    {
        using (var client = new HttpClient())
        {
            string s = "https://prevoz.org/api/search/shares/?";
            s += "f=" + fromCity+"&";
            s += "fc=SI" + "&";
            s += "t=" + toCity + "&";
            s += "tc=SI"  + "&";
            s += "d=" + date.ToString("yyyy-MM-dd");
            var z = await client.GetAsync(new Uri(s));
            List<CarshareList> moj = new List<CarshareList>();
            var y = await z.Content.ReadAsAsync<CarshareResponse>();
            foreach (var a in y.CarshareList)
                    moj.Add(a);
            return moj;
        }
    }

When I call the service from my laptop at home network I receive results in UWP and Android application (can't test for iOS). It all works fine. When I run the same code (same laptop) at school I don't receive any result. I've tried to debug my project and in line

  var z = await client.GetAsync(new Uri(s));

returns to MainPage. This happens always in school. z doesn't have any return code. If I copy URL for my call in web browser (at school) I get the normal JSON results. What am I missing? Thanks, Barbara

  • `What am I missing?` Probably a proxy configuration. Check to see if your browser has proxy settings. – Stephen Cleary Jun 12 '17 at 14:53
  • You may have your home IP address whitelisted by the API so that it works there but not elsewhere. See if the API you are calling has settings tied to your IP address. – Zach Sadler Jun 12 '17 at 14:55

0 Answers0