I need to pass a concatenated string as a web api url RRS feed

  • Question

  • User298610 posted

    I am developing a PCL Project in Xamarin .I need to pass the IP Address of the device dynamically in the web api Url. My Code is as below:

    In the code behind:

    string IpAdd = txtIP.Text;

    IPAddress = "http://" + IpAdd + ":8124/api/Items/";

    MainViewModel.FinalIPAddress = IPAddress;

    In my MainViewModel

    public static string FinalIPAddress { get; set; }

    public static readonly string WebServiceUrl = System.Net.WebUtility.UrlEncode(FinalIPAddress);

    But I am unable to get through this. The below exception gets thrown.

    *Exception thrown: 'System.InvalidOperationException' in System.Net.Http.Phone.ni.DLL Additional information: An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set. * How to go about with this? Any help will be appreciated. Thanx in advance.

    Tuesday, April 11, 2017 5:49 PM

All replies

  • User350 posted

    If you step through the code, what is the value of WebServiceUrl just before the error? Sounds like it's malformed (but you know that).

    I also question why you're using the device's IP address in an HTTP call. Is the other end on the device? If not this doesn't make sense.

    Saturday, April 15, 2017 7:01 AM
  • User65389 posted

    What are you calling in System.Net.Http.Phone.ni.DLL ?

    Monday, April 17, 2017 8:18 PM