使用Tridion UGC Web服务添加评级

Joh*_*ohn 3 ugc tridion tridion-content-delivery tridion-2011

我知道我可以通过使用以下内容通过UGC Web服务添加评论: -

WebServiceClient ugcCall = new WebServiceClient();

string ugcData = "{ \"d\" :{\"Content\":\"" + comment + "\",\"Status\":2,\"ItemPublicationId\":\"" + PublicationId + "\",\"ItemId\":\"" + itemid + "\",\"ItemType\":\"16\",\"Id\":0,\"ModeratedDate\":\"\",\"LastModifiedDate\":\"\",\"CreationDate\":\"\",\"Score\":0,\"Moderator\":\"\",\"User\":{\"Id\":\"ACME%5Cjbloggs\",\"Name\":\"Joe Bloggs\"}}}";

string result = ugcCall.UploadString("/Comments", "POST", ugcData);
Run Code Online (Sandbox Code Playgroud)

我的问题是添加评级和喜欢和不喜欢的语法是什么?这记录在哪里?

MTIA

约翰

Qui*_*ijn 5

上传评级的命令是'/ Ratings'而不是'/ Comments'.当然,JSON也不同.在下面的代码中,我不会手动编写JSON,而是构建一个简单的Rating对象并使用JavascriptSerializer将其转换为JSON:

TcmUri tcmUri = new TcmUri(itemUri);
WSR_ContentDelivery.User user = new WSR_ContentDelivery.User { Id = GetUserId() };
WSR_ContentDelivery.Rating rating = new WSR_ContentDelivery.Rating
{
  CreationDate = DateTime.UtcNow,
  LastModifiedDate = DateTime.UtcNow,
  ItemPublicationId = tcmUri.PublicationId,
  ItemId = tcmUri.ItemId,
  ItemType = tcmUri.ItemTypeId,
  RatingValue = ratingValue.ToString(),
  User = user,
  Id = "0"
};

JavaScriptSerializer oSerializer = new JavaScriptSerializer();

WSClient.UploadString("/Ratings", "POST", "{d:" + oSerializer.Serialize(rating) + "}", GetUserId());
Run Code Online (Sandbox Code Playgroud)