please see your code and tell me what will be the address
sorry to ask few question. please answer that will guide me.
code taken from this area https://www.codeproject.com/Articles/1005485/RESTful-Day-sharp-Security-in-Web-APIs-Basic#_Toc423441907
- [GET("allproducts")]
- [GET("all")]
- public HttpResponseMessage Get()
- {
- }
- [GET("productid/{id?}")]
- [GET("particularproduct/{id?}")]
- [GET("myproduct/{id:range(1, 3)}")]
- public HttpResponseMessage Get(int id)
- {
- }
- [POST("Create")]
- [POST("Register")]
- public int Post([FromBody] ProductEntity productEntity)
- {
- }
- [PUT("Update/productid/{id}")]
- [PUT("Modify/productid/{id}")]
- public bool Put(int id, [FromBody] ProductEntity productEntity)
- {
- }
- // DELETE api/product/5
- [DELETE("remove/productid/{id}")]
- [DELETE("clear/productid/{id}")]
- [PUT("delete/productid/{id}")]
- public bool Delete(int id)
- {
- }
will it be api/product ?
2) what will be the address of this action public HttpResponseMessage Get(int id)
will it be api/product/5 ?
- [GET("productid/{id?}")]
- [GET("particularproduct/{id?}")]
- [GET("myproduct/{id:range(1, 3)}")]
- public HttpResponseMessage Get(int id)
- {}
first 2 gets look same......is not it ?
3)
- [POST("Create")]
- [POST("Register")]
- public int Post([FromBody] ProductEntity productEntity)
- {
- return _productServices.CreateProduct(productEntity);
-
what two post is there with different keyword ?
what is the meaning of text inside post keyword like [POST("Create")] ?
4)
- [DELETE("remove/productid/{id}")]
- [DELETE("clear/productid/{id}")]
- [PUT("delete/productid/{id}")]
- public bool Delete(int id)
- {
- if (id > 0)
- return _productServices.DeleteProduct(id);
- return false;
- }
why delete and post 2 verbs have been used for single action called Delete ?
please answer in details. thanks
Sakthivel GanesanPosted Jun 11, 2017, 11:43 PM
will it be api/product ?
will it be api/product/5
- http://hostingdomain/api/product/productid/5
- http://hostingdomain/api/product/particularproduct/4
- http://hostingdomain/api/product/myproduct/3 (If you're using myproduct, then the Id range should be 1 to 3)
3) what will be the action url for Post action above?