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