c# - POST Complex Object to ApiController Subclass -


i working on api method should accept image model object, has property list<comment> comments. image posted mobile app works fine if include array of comment objects aren't showing on instance of image. i'm not super great c# appreciated.

image class

public class image {     public int? imageid { get; set; }     [required]     public string image { get; set; }     [required]     public string contenttype { get; set; }     [required]     public string filename { get; set; }     [required]     public datetime datetaken { get; set; }     [required]     public int userid { get; set; }     [required]     public int companyid { get; set; }     [required]     public int locationid { get; set; }     public decimal? lat { get; set; }     public decimal? long { get; set; }     public list<apicomment> comments { get; set; } } 

comment class

public class apicomment {     [required]     public string comment { get; set; }     [required]     public datetime datecreated { get; set; }     [required]     public int userid { get; set; } } 

beginning of imagescontroller

public class imagescontroller : apicontroller  {     [system.web.http.httppost]     public actionresult post(image image) 

i believe there's wrong request body of request:

i tried in fiddler:

{ "comments" : [{ "comment" : "hello"}, {"comment" : "world"}]} 

and got 2 counts comments in webapi action method.

check there no typo error request object posting , json valid.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -