I want to build a dynamic structure for a client to ask server in web API. I have tried to use the following code to deal with my question, however, it isn't working.
- How can I send a generic type like
<travel>to service- How can I change server code (or all need to change client/server)?
PS:Thank you for your patience if you have read my question to the end.
Client Code
var serializer = new JavaScriptSerializer();    
var product = new travel() { travel_desc = "select * from travel" };    
var jsonText = serializer.Serialize(product);    
var client = new HttpClient();    
client.BaseAddress = new Uri("http://localhost:65370/");     
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));    
StringContent content = new StringContent(jsonText, Encoding.UTF8, "application/json");     
var z = client.PostAsync<travel>("api/bb", product, new JsonMediaTypeFormatter()).Result;
Server Code, which is not working
public IHttpActionResult Post< T > (Object x) where T : new()    
{    
                ........................    
}
by the way it is okay but i don't know how to send < T > to server
public IHttpActionResult Post(Object x)    
{    
                ........................    
}     
Error message
Client call server, server will be getting an error message " StatusCode: 404, ReasonPhrase: 'Not Found' "
 var z = client.PostAsync < travel > ("api/dd", product, new JsonMediaTypeFormatter()).Result; <--client
    public class ddController< T > : ApiController {public virtual void Post() {   ... }  } <---server    
  // sorry all , my English isn't very well , so I will try to use code to tell everyone how i want 
// in format situations,I will create 2 controller when I have 2 models(ex: users/product) , as following (client)
                var a = client.PostAsync("api/users", users, new JsonMediaTypeFormatter()).Result;
                var b = client.PostAsync("api/product", product, new JsonMediaTypeFormatter()).Result;
//and then when the users and product controllers was created the post code should be like as following (server)
                public IHttpActionResult Postusers(users travel) {}
                public IHttpActionResult Postproduct(product travel) {}
   //now i just want to create 1 controller for above  like as follwing 
                 var b = client.PostAsync<users/product>("api/all", product, new JsonMediaTypeFormatter()).Result;(client)
                 public IHttpActionResult Post<T>(Object ForAll) where T : new() {} (server)
 
     
    