public HttpResponseMessage getBookNames() { List <BookDetails> list = new List <BookDetails>(); BookDetails u = new BookDetails(); list = u.getBookNames(); string yourJson = JsonConvert.SerializeObject(list);; var response = this.Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(yourJson, Encoding.UTF8, "application/json"); return(response); }