System.NullReferenceException: Unable to deserialize object from response body of type CommunityServer.WebServices.Serialization.MediaGalleries.MediaGalleryPostListSerialized

Not Answered This post has 0 verified answers | 6 Replies | 4 Followers

Not Ranked
23 Posts
Points 360
Paras Wadehra posted on Mon, Oct 6 2008 6:59 PM

Hi, I have the following code in my CS 2008.5 application:

MediaGallery mg = new MediaGallery();
MediaGalleriesService mgs = new MediaGalleriesService("http://localhost/cs/", "admin", "j1msc66y");
PagedList<MediaGalleryPost> mediaposts = mgs.GetMediaGalleryPosts(3); // >>>>> Error is on this line
int Cnt = mediaposts.Count;

When I run the app, I get the following error:

System.NullReferenceException: Unable to deserialize object from response body of type CommunityServer.WebServices.Serialization.MediaGalleries.MediaGalleryPostListSerialized

Can somebody help resolve this problem?

Regards,
Paras

All Replies

Top 75 Contributor
Male
266 Posts
Points 1,140

There are two ways you can see what is happening. One is to use Fiddler (http://www.fiddlertool.com) to watch the requests and responses moving back and forth. The other would be to hit the URL that this method calls (probably http://localhost/cs/api/mediagalleries.ashx/api/mediagalleries.ashx/posts/keywords=;mediagalleryids=3;mediagallerypostsortby=PostDate;ids=;keys=;groupids=;pageindex=0;pagesize=20) and see if you get results.

I have been noticing a bug in releases of the API assembly SINCE the one on http://api.communityserver.com that adds a "?" to the front of any request that uses a Query. There was a breaking change (read: bug) in later builds that now call BaseQuery.ToQueryString instead of BaseQuery.ToPathString. I'm not sure  how it got in there, but it basically broke the entire API in every subsequent release.

I have a message into Telligent to fix it. In the meantime, download the old API from here: http://api.communityserver.com/download and use that for now instead. Don't worry, you won't lose much functionality... it doesn't appear that much has been added since that build. I know they certainly didn't fix anything else that has been broken.

  • Filed under:
  • | Post Points: 20
Top 75 Contributor
Male
276 Posts
Points 4,210

Hello Interscape. I upgraded to CS 2008.5 and it appears that I'm totally unable to make the API proxies work. 

I receive the same exception message when I try to get the existing blogs list.  What's the problem? Is there some fix to correctly connect to the API?

Thanks!!

José Manuel Nieto
Translator of the Spanish Language Pack for Community Server 2008
Developer of CS Writer

  • | Post Points: 20
Top 75 Contributor
Male
266 Posts
Points 1,140

If you don't need to support older versions, then use the CommunityServer.WebServices.dll from the CS2008.5 installation. If you do, then you'll need to wait a little bit for more details. :(

  • | Post Points: 20
Top 10 Contributor
5,284 Posts
Points 49,035
CS Developers

I believe support had already responded to you directly, but since the thread came up again, wanted to post a response.

Firstly, the error is just a generic one.  You'll get that kind of error message from the client API anytime the service side returns an error, either from actual exceptions or just a "permission denied".  Right now, the client API doesn't do a good job of handling error statuses from the service, which we are working on.  It can't deserialize the intended object because the service returned an error.

As for the change in handling queries, we did this because we found more complex queries, which had longer request URLs, were hitting the maximum URL length within IIS.  We changed all query objects to use the query string instead.

This was not a breaking change though.  The service side still support path queries.  We merely beefed up support for query strings, allowed them to be used interchangeably on the service side, and changed the client API to use the path strings.  You code for doing queries will be exactly the same, regardless, and if you had any raw queries to the API using path queries, they still work as they did before.

If you were getting an error with a query, it was likely related to something else.  Since the client API doesn't report those well right now, it would be best to capture the URL it was hitting and then access it directly with your browser.  You'll see the actual XML response, which would hopefully point you in the right direction.

  • | Post Points: 20
Top 75 Contributor
Male
266 Posts
Points 1,140

Actually, Ken... It was a breaking change. If you try using the new assembly from CS2008.5 on anything earlier than CS2008.5, it stops functioning when you call anything that gets a subset of a blog group/media group/etc. I traced the problem back to the fact that the URLs were different, and traced that problem back to the fact that BaseQuery is deserialized with .ToQueryString now instead of .ToUrlString (or whatever, I'm not looking at the code right this second.) After doing a diff on the assemblies, I found that all the major calls switched, without any compatibility for handling both. Anything earlier than CS2008.5 returns a 404 if you use a querystring instead of a URL for the query parameters.

I ran into this problem because, all of a sudden, my code stopped working after an upgrade. I wasted 6 hours trying to track it down. Wasted countless subsequent hours writing workaround code for it.

  • | Post Points: 20
Top 500 Contributor
50 Posts
Points 565
mattb replied on Sun, Oct 26 2008 8:34 PM

I'm using CS2008 and stuck - getting the same general error above. What should we do?

http://community2.metalreview.com/forums

  • | Post Points: 5
Page 1 of 1 (7 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com