Receive data through WebAPI Post and webapipost
Recently, I am writing a webapi interface for an open-source marketplace. I have encountered some problems due to my new contact, such as receiving post data. Three methods are provided for online data query.
1. encapsulate multiple data objects into one object for receiving ([frombody] labels can only be used for one parameter. For details, refer to the previous blog)
2. Use formcollection to receive data (the key here is that all the information found on the internet is received with formcollection. In actual testing, the request is successful, but no data can be obtained. I have been wondering whether I have done wrong, and later found that this type of introduction source from a blog http://www.dotblogs.com.tw/regionbbs/archive/2013/01/10/web.api.method.and.routing.aspx#72397, after consulting the blogger, found that it was wrong. In webapi, The FormDataCollection of System. Net. Http. Formatting must be used)
3. Use JObject to declare
If JSON is required, we can use JObject in Json. NET to implement:
Then, the POST Content must be in JSON format and the required Content-Type must be set to application/json ),