In WebAPI, the object I pass to the OK ResponseMessage does not get serialized properly. RRS feed

  • Question

  • Hi, I have written a RestAPI using WebAPI on .Net 4.5.2 etc.

     I pass back an OK along with some response information. However the object I pass back is only being partially serialized.

    Here is my class I am passing in. 

        public class ResponseMessage
            public int Code { get; set; }
            public string Message {get; set;}
            public ResponseMessage(ResponseCodes Code, string Message)
                this.Code = (int)Code;
                this.Message = Message;

    and here is the calling code

    return Ok<ResponseMessage>(MyResponseMessageObj);

    So I would expext both the Code and the Message to be return to the client, however this is all I get.

    "message": "No content found"

    Any ideas? Why is "Code" note being serialised? I also tried explicitly defining the class and objects using DataContract and DataMember attributes...

    Thanks in advance,


    • Edited by lrak1 Monday, December 1, 2014 6:40 AM
    Monday, December 1, 2014 6:39 AM


All replies