I'm just trying to run a little prototype that posts UGC comments using the UGC web service.
The code example is below. I'm getting a 403 response from the web service which indicates I'm not authorised to use the service so I presume I need to create an authentication header? Does anybody have any examples of how to post comments using the UGC web service?
string ugcData = "{d\":{\"Content\":\"FROM WEB SERVICE\",\"Status\":2,\"ItemPublicationId\":\"68\",\"ItemId\":\"17805\",\"ItemType\":\"16\",\"Id\":0,\"ModeratedDate\":\"\",\"LastModifiedDate\":\"\",\"CreationDate\":\"\",\"Score\":0,\"Moderator\":\"\",\"User\":{\"Id\":\"DOMAIN%5Cbsmith\",\"Name\":\"Bill Smith\"}\"}";
WebServiceClient ugcCall = new WebServiceClient();
ugcCall.UploadString("/PostData", "POST", ugcData);
MTIA.
John
You should try to post on the Comments collection:
ugcCall.UploadString("/Comments", "POST", ugcData);
Then you will see that you're missing the CreationDate, moment in which you need to add to your entity something like:
\"CreationDate\":\"/Date(1359457694472)\"
(I have not actually checked if you need more quotes in there). For the format of the date in a JSON string check the odata specs.
If you still have problems, try to change DOMAIN%5Cbsmith
to another dummy value ('test
' for example).
If that is not enough then maybe you can look at the logs generated by the UGC WebService and try to make-out some stack-trace.
One more thing to notice here: the UGC properties need to be defined correctly in the Web.config in order for the post to even happen.
Hope this helps.