Could not deserialize data returned from server - Binaries don't fix this

Apr 6, 2010 at 4:40 PM

Hi Everyone,

I am fairly new to developing facebook applications, but simply cannot get my code to work using the c# library.

I am developing a FBMLCanvas application, using the Master page method that is in most of the tutorials online.

I am getting the "Could not deserialize data returned from server" error as I have seen others have on the boards, but I have used the latest binaries and the problem is still persisting. I have downloaded the 49014 build, and it is still not working...

Could it be possible that this is a server issue on my side? If so, how will I be able to address the issue?

my code looks something like (the line of code that causes the exception is highlighed):

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Facebook.Schema;

namespace FacebookFMBL
{
    public partial class Default : System.Web.UI.Page
    {

        public user LoggedInUser
        {
            get
            {
                return Master.Api.Users.GetInfo();
            }
        }

        protected void Page_PreInit(object sender, EventArgs e)
        {
            Master.RequireLogin = true;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            Master.selected = "tab_home";
        }

        protected void submit_click(object sender, EventArgs e)
        {
            try
            {
                litMessage.Text = LoggedInUser.name;
            }
            catch (Exception ex)
            {
                litErrorMessage.Text = ex.Message;
                litStack.Text = ex.StackTrace;
            }

        }
    }
}

Error: Could not deserialize data returned from server
Stacktrace: at Facebook.Utility.Utilities.DeserializeXML[T](String xmlInput) at Facebook.Rest.RestBase.SendRequest[T](IDictionary`2 parameterDictionary, Boolean useSession, Boolean useJson) at Facebook.Rest.Users.GetInfo(String uids, Boolean isAsync, GetInfoCallback callback, Object state) at Facebook.Rest.Users.GetInfo(Int64 uid) at Facebook.Rest.Users.GetInfo() at FacebookFMBL.Default.get_LoggedInUser() at FacebookFMBL.Default.submit_click(Object sender, EventArgs e)
 

 

 

 
Developer
Apr 6, 2010 at 5:54 PM
Make sure you download the latest from the source tree to make sure, beta 3.1 Also check to see what xml is returning from facebook. We are not seeing any issues with our apps which are live.
Apr 12, 2010 at 8:24 PM

I just got the 3.1 BETA and am getting the same "Could not deserialize data returned from server" error when calling:

 

IList<album> albums = _facebookAPI.Photos.GetAlbums();

 

Apr 12, 2010 at 8:29 PM

I managed to sort out the reason why I was getting the exception, it was not anything related to the SDK.

It turned out that my internal firewall (barracuda) was blocking any information coming from Facebook, adding Facebook to the list of acceptable sites removed the error from happening and it has been smooth sailing since.

I have noticed a couple of threads that mention the error with the .GetAlbums() method call, but personally I have not had the need for that in my current application.

Best of luck,

Tribe84

Apr 12, 2010 at 8:32 PM

Well, this is the XML coming back

 

<?xml version="1.0" encoding="UTF-8"?>
<photos_getAlbums_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
  <album>
    <aid>100000963655235_-3</aid>
    <cover_pid>0</cover_pid>
    <owner>100000000000005</owner>
    <name>Profile Pictures</name>
    <created  xsi:nil="true"/>
    <modified  xsi:nil="true"/>
    <description xsi:nil="true"/>
    <location xsi:nil="true"/>
    <link>http://www.facebook.com/album.php?aid=-3&amp;id=100000000000005</link>
    <size>0</size>
    <visible>everyone</visible>
    <modified_major  xsi:nil="true"/>
    <type>profile</type>
    <object_id>0</object_id>
    <edit_link>http://www.facebook.com/editphoto.php?aid=-3</edit_link>
    <can_upload>0</can_upload>
  </album>
</photos_getAlbums_response>

It's failing on the line:

return (T)xs.Deserialize(memoryStream);

 

 

Apr 12, 2010 at 8:46 PM
Edited Apr 12, 2010 at 8:52 PM

Some more information on this error. The actual exception error is:

 

{System.InvalidOperationException: There is an error in XML document (16, 6). ---> System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
   at System.Xml.XmlConvert.ToInt64(String s)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderphotos_getAlbums_response.Read2_album(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderphotos_getAlbums_response.Read3_photos_getAlbums_response(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderphotos_getAlbums_response.Read4_photos_getAlbums_response()
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(Stream stream)
   at Facebook.Utility.Utilities.DeserializeXML[T](String xmlInput)}

 

Facebook API states that this is an example of what the XML should look like when coming back:

 

<?xml version="1.0" encoding="UTF-8"?>
 <photos_getAlbums_response xmlns="http://api.facebook.com/1.0/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
  <album>
    <aid>34595963571485</aid>
    <cover_pid>34595991612812</cover_pid>
    <owner>8055</owner>
    <name>Films you will never see</name>
    <created>1132553109</created>
    <modified>1132553363</modified>
    <description>No I will not make out with you</description>
    <location>York, PA</location>
    <link>http://www.facebook.com/album.php?aid=2002205&id=8055</link>
    <size>30</size>
    <visible>friends</visible>
    <modified_major>1241834423</modified_major>
  </album>
 </photos_getAlbums_response>

 

Apr 12, 2010 at 9:29 PM

This is a known issue due to there not being a profile photo. Issue reopened here: http://facebooktoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=17208