Return ItemStats from Tridion UGC

I was wondering if anyone could suggest any pointers to this one. I try to return ItemStats from the Tridion UGC web service, but when I try to link the results, I get the following error: -

The private type TridionWebUGC.CDS.ItemStat does not have the corresponding LastRatedDate property.

Code example: -

WebServiceClient ugcCall2 = new WebServiceClient(); Uri uri = new Uri("http://new.ugc.service/odata.svc"); CDS.ContentDeliveryService cds = new CDS.ContentDeliveryService(uri); var myItemStats = cds.ItemStats.Where(p => p.PublicationId == 68 && p.Id == 17792 && p.Type==16); 

I can get comments and ratings without any problems. For instance.

  var myComments = cds.Comments.Where(p => p.ItemId == 17805).OrderBy(p => p.CreationDate); 

These are just ItemStats that give me a problem. Anyone any ideas?

thanks

John

+6
source share
1 answer

Unfortunately, the UGC WebService metadata is incorrect with respect to ItemsStats. For you, this means that the webservice metadata does not disclose the fact that the ItemStat contains the LastRatedDate property. This makes your .NET proxies unaware of this property and makes your request complete. To get around this defect, you have two options:

  • Add the following property to your service: cds.IgnoreMissingProperties = true The advantage of this approach is that you are done with it in 2 seconds. The disadvantage is that you will not be able to access this property (in case of its actual use);
  • Modify the proxies created by Visual Studio and manually add this property to the ItemStat class. The advantage of this approach is that you can access the property from your project. The disadvantage is that it is not completely controlled in terms of coding, you need to be careful when updating or regenerating proxies, and it is easy to make a mistake when manually adding a property.

Note 1: to access the metadata of your web server from a browser, you can go to /odata.svc/$metadata .

Note 2: when viewed in more detail, the webService metadata does not have 2 properties: LastRatedDate and LastCommentedDate .

Hope this helps.

+8
source

All Articles