Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

I am studying the course XAM150 to do with REST, and I get WebExceptionStatus.NameResolutionFailure

I am studying the Xamarin University course XAM150 to learn about REST.
For exercise 2, with this code;

    private string authorizationKey;
    private const string Url = "http: //xam150";

    private async Task<HttpClient> GetClient()
        var client = new HttpClient();
        if (string.IsNullOrEmpty(authorizationKey))
                var token = await client.GetStringAsync(Url + "login");
                authorizationKey = JsonConvert.DeserializeObject<string>(token);
            catch (Exception ex)
                var i = 0;

The line ; var token = await client.GetStringAsync(Url + "login");
Throws an exception;

When I take the url and paste it into a browser I get the authorizationKey as a Guid OK.
So how do I fix this?



  • wesleyfavarinwesleyfavarin USMember ✭✭



    you not need sent the token ?

    your url contains spaces, remove the spaces, maybe it is that
    "http: //xam150"

    let me know if it's right.

  • arame3333arame3333 GBMember ✭✭
    edited February 2018

    I had to put spaces in the url in order to post the question. In my code they do not exist. As a new member of this forum I am not allowed to post links.

  • Gigex42Gigex42 USMember ✭✭✭✭

    Did you try calling your webseite from the webbrowser? Does it give any error?

    Also it sounds like it cannot resolve the host name. Try IP instead to test if it works.

  • arame3333arame3333 GBMember ✭✭
    edited February 2018

    In my question I mention that I put the url in my browser and I get a valid response. You can try it too. However I do not know the IP address of the url.

Sign In or Register to comment.