Text after "
I want to collect userInfo from DotNetNuke from my Javascript webpage. To collect it I use $ .getJSON:.
$ getJSON ( "/ DesktopModules / myModule / API / service / GetUsers", "portalId = 2", function (ALLDATA) {var mappedUsers = $ Kmap (all data, function (item ) {New myModule.User (item);}); User itself (mapped user);});
I have this service controller:
public class ServiceController: DnnApiController {[AllowAnonymous] [HttpGet] public HttpResponseMessage GetUsers (int portalId) {myController controller = New myController (); Array list item = controller Gateways (portal id); Return request. Caterpillars (HTTTata code.OK, item); }} Public class myController //: ISearchable, IPortable {public ArrayList GetUsers (integer portalId) {return UserController.GetUsers (portalId); }}
DNN API According to the document has been defined as the method:
public static ArrayList GetUsers (int portalId)
< / pre>but when I test my service in a browser it fails with an error: "type 'DotNetNuke.Entities.Users.UserInfo' with data contract name 'UserInfo:'. do not expect a DataContractResolver Consider using or in some way do not know statically in the list of known types - for example, Known By using the TypeAttribute attribute or adding them to the list of known types near the DataContractSerializer. "
Any ideas how to solve it?
The problem is that you can do serial to Ugrinaf without installing custom serialization. UserInfo object can not be automatically serialized to JSON. The simplest way in your answer is to create your own object representing the UserInfo - either a cut down class or only the individual properties are needed.
Comments
Post a Comment