Question

On my windows phone 7 Mango app I use the Microsoft.Live and Microsoft.Live.Controls references to download and upload on Skydrive. Logging in and uploading files works fine but whenever I call the "client.GetAsync("/me/skydrive/files");" on the LiveConnectClient the Callback result is empty just containing the error: "An error occurred while retrieving the resource. Try again later."

I try to retrieve the list of files with this method.

This error suddenly occured without any change on the source code of the app (I think..) which worked perfectly fine for quite a while until recently. At least I didn't change the code section for up- or downloading.

I tried out the "two-step verification" of Skydrive, still the same: can log in but not download. Also updating the Live refercences to 5.5 didn't change anything.

Here is the code I use. The error occurs in the "getDir_Callback" in the "e" variable. Scopes (wl.skydrive wl.skydrive_update) and clientId are specified in the SignInButton which triggers "btnSignin_SessionChanged".

private void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
    {
        if (e.Status == LiveConnectSessionStatus.Connected)
        {
            connected = true;

            processing = true;
            client = new LiveConnectClient(e.Session);

            client.GetCompleted +=  new EventHandler<LiveOperationCompletedEventArgs>(OnGetCompleted);
            client.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(UploadCompleted);
            client.DownloadCompleted += new EventHandler<LiveDownloadCompletedEventArgs>(OnDownloadCompleted);
            client.DownloadProgressChanged += new EventHandler<LiveDownloadProgressChangedEventArgs>(client_DownloadProgressChanged);

            infoTextBlock.Text = "Signed in. Retrieving file IDs...";
            client.GetAsync("me");


        }
        else
        {
            connected = false;
            infoTextBlock.Text = "Not signed into Skydrive.";
            client = null;
        }
    }


    private void OnGetCompleted(object sender, LiveOperationCompletedEventArgs e)
    {
        if (e.Error == null)
        {
            client.GetCompleted -= new EventHandler<LiveOperationCompletedEventArgs>(OnGetCompleted);
            client.GetCompleted += getDir_Callback;
            client.GetAsync("/me/skydrive/files");

            client_id = (string)e.Result["id"];

            if (e.Result.ContainsKey("first_name") && e.Result.ContainsKey("last_name"))
            {
                if (e.Result["first_name"] != null && e.Result["last_name"] != null)
                {
                    infoTextBlock.Text = "Hello, " +
                        e.Result["first_name"].ToString() + " " +
                        e.Result["last_name"].ToString() + "!";
                }
            }
            else
            {
                infoTextBlock.Text = "Hello, signed-in user!";
            }
        }
        else
        {
            infoTextBlock.Text = "Error calling API: " +
                e.Error.ToString();
        }

        processing = false;
    }

    public void getDir_Callback(object s, LiveOperationCompletedEventArgs e)
    {
        client.GetCompleted -= getDir_Callback;

        //filling Dictionary with IDs of every file on SkyDrive
        if (e.Result != null)
            ParseDir(e);

        if (!String.IsNullOrEmpty(e.Error.Message))
            infoTextBlock.Text = e.Error.Message;
        else
            infoTextBlock.Text = "File-IDs loaded";
    }
Was it helpful?

Solution 2

It miraculously works again without me changing any code. It seems to be resolved on the other end. I have no clue what was wrong.

OTHER TIPS

Yo shall use client.GetAsync("me/SkyDrive/files", null) in place of client.GetAsync("me"); This is my code and it works fine.

 private void btnSignIn_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
        {
            try
            {

                if (e.Session != null && e.Status == LiveConnectSessionStatus.Connected)
                {
                    client = new LiveConnectClient(e.Session);
                    client.GetCompleted += new EventHandler<LiveOperationCompletedEventArgs>(client_GetCompleted);
                    client.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(client_UploadCompleted);
                    client.GetAsync("me/SkyDrive/files", null);
                    client.DownloadAsync("me/SkyDrive", null);
                    canUpload = true;
                    ls = e.Session;

                }
                else
                {
                    if (client != null)
                    {
                        MessageBox.Show("Signed out successfully!");
                        client.GetCompleted -= client_GetCompleted;
                        client.UploadCompleted -= client_UploadCompleted;
                        canUpload = false;
                    }
                    else
                    {
                        canUpload = false;
                    }
                    client = null;
                    canUpload = false;

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

void client_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
        {
            try
            {
                List<System.Object> listItems = new List<object>();
                if (e.Result != null)
                {
                    listItems = e.Result["data"] as List<object>;
                    for (int x = 0; x < listItems.Count(); x++)
                    {
                        Dictionary<string, object> file1 = listItems[x] as Dictionary<string, object>;
                        string fileName = file1["name"].ToString();
                        if (fileName == lstmeasu[0].Title)
                        {
                            folderID = file1["id"].ToString();
                            folderAlredyPresent = true;
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("An error occured in getting skydrive folders, please try again later.");
            }
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top