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