Windows Phone 8.1 Google Book REST Api call with HttpClient: HRESULT: 0x80072EFD

3

I am trying to write some app that needs to fetch info about books. That's why I am using Google Book Api. The Official library is not working on WP8.1 so I am trying to do everything by myself with the help of the Internet. That is what I wrote:

 public async Task<RootObject> GetBooks(string query)
    {

        using (HttpClient httpClient = new HttpClient())
        {
            HttpResponseMessage response = new HttpResponseMessage();

            string requestUri = googleApiUri + "q=" + query.Replace(" ", "+") + "&maxResults=10&orderBy=relevance&printType=books&projection=lite";
            string jsonString = "";
            try
            {
                jsonString = await httpClient.GetStringAsync(new Uri(requestUri));
            }
            catch (Exception ex)
            {
                string message = "Error = " + ex.HResult.ToString("X") +
                "  Message: " + ex.Message;
            }

            return ResponseToJson(jsonString);

        }
    }

    private RootObject ResponseToJson(string message)
    {
        return JsonConvert.DeserializeObject<RootObject>(message);
    }

However, the call httpClient.GetStringAsync is throwing me an error: "Exception from HRESULT: 0x80072EFD". I've no idea why's that happening and I can't find anything on the Internet about such exception. Am I doing something wrong with httpClient? I will be very greatful for any help!

Thank You in advance!

BestRegards, Roman

c#
windows-phone-8

1 Answer

0

Do you have suffisent authorization for your app ? Usually, there is a file called WMAppManifest.xml in the Properties of your project. Open it and go to the "Capabilities" tab. Make sure ID_CAP_NETWORKING is checked. This will give your app the authorization to access the Internet.

answered on Stack Overflow May 4, 2014 by gretro

User contributions licensed under CC BY-SA 3.0