TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
tri_inn
NA
1.2k
235.3k
Web api related few questions
Jun 8 2017 10:43 AM
i have seen few code of your article. i am new in web api. so i just do not understand if i need to call these action then what will be their address or url?
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)
{
}
1) what will be the address of this action public HttpResponseMessage Get()
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)
{}
why you decorate a single action with so many gets attribute ?
first 2 gets look same......is not it ?
3)
[POST(
"Create"
)]
[POST(
"Register"
)]
public
int
Post([FromBody] ProductEntity productEntity)
{
return
_productServices.CreateProduct(productEntity);
what will be the action url for Post action above ?
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
Reply
Answers (
1
)
genrate SeatMapReq c# in travelport
Add token Bearer in Post Method Rest API in C#