I am getting remote server not found error with https url request

I am developing a Windows Phone 8 app that receives video streams from youtube api data. I am doing httpWebRequest https://gdata.youtube.com/feeds/api/videos?max-results=10&v=2&alt=jsonc&q=fondoflamenco

but I am getting the error "Remote Server: Not Found". I have Windows 8 devices connected to the same network.

this is the source code:

Uri targetUri = new Uri("https://gdata.youtube.com/feeds/api/videos?max-results=10&v=2&alt=jsonc&q=fondoflamenco");
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(targetUri);
request.Method = "GET";
request.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), request);

      

ReadWebRequestCallback code:

        private void ReadWebRequestCallback(IAsyncResult callBackResult)
    {
        HttpWebRequest myRequest = (HttpWebRequest)callBackResult.AsyncState;
        try
        {
            HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callBackResult);
            using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream()))
            {
                var results = httpwebStreamReader.ReadToEnd();
                JObject jsonObject = JObject.Parse(results);
                JArray items = JArray.FromObject(jsonObject["items"]);
                List<Video> videos = new List<Video>();
                foreach (var item in items)
                {
                    Video video = new Video();
                    video.descripcion = item["description"].ToString();
                    if (item["player"]["mobile"] != null)
                    {
                        video.url = item["player"]["mobile"].ToString();
                    }
                    video.imagen = new System.Windows.Media.Imaging.BitmapImage(new Uri(item["thumbnail"]["sqDefault"].ToString()));
                    videos.Add(video);
                }
                Dispatcher.BeginInvoke(delegate()
                {
                    MediaList.ItemsSource = videos;
                });

            }
        }
        catch (WebException ex)
        {
            //Dispatcher.BeginInvoke(delegate() { DescriptionBox.Text = ex.Message; });
            throw;
        }

    }

      

What is wrong I am doing to get the remote server error: not found

+3


source to share


1 answer


I just decided to add blank credentials to the https requests like

    myRequest.Credentials = new NetworkCredential("", "");

      



here he explains it better

http://blog.toetapz.com/2010/11/15/windows-phone-7-and-making-https-rest-api-calls-with-basic-authentication/

0


source







All Articles