Find the answer to your question
Advanced Search
How to retrieve the WatchCount() info from GetSellerEvents or GetItem API calls
To retrieve WatchCount property in an item node, one needs to call set IncludeWatchCount property to specifies whether to return the value when making GetSellerEvents or GetItem request. The count can be retrieved through the raw api calls only since the setter is not available on the correspondent wrapper class .
NOTE. 1. WatchCount is only returned with DetailLevel ReturnAll.
2. You must be the seller of the item to retrieve the watch count via GetItem call.
The code sample for getting watchcount from GetItem request is listed below:
ApiCall api = new ApiCall(apiContext);
ItemIDType itemID = new ItemIDType("xxxxxxx");
DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] {
DetailLevelCodeType.ReturnAll,
};
api.setDetailLevel(detailLevels);
GetItemRequestType request = new GetItemRequestType();
request.setItemID(itemID);
request.setIncludeWatchCount(new Boolean("true"));
GetItemResponseType resp = (GetItemResponseType)api.executeByApiName("GetItem",request);
ItemType item = resp.getItem();
String watchCt = item.getWatchCount());