Base solution for your next web application
Open Closed

Creating API best practices #4042


User avatar
0
soonjoo created

Hello team,

How do I create API like the recommended: <a class="postlink" href="http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api#restful">http://www.vinaysahni.com/best-practice ... pi#restful</a>

GET /tickets - Retrieves a list of tickets GET /tickets/12 - Retrieves a specific ticket POST /tickets - Creates a new ticket PUT /tickets/12 - Updates ticket #12 PATCH /tickets/12 - Partially updates ticket #12 DELETE /tickets/12 - Deletes ticket #12

I see these are the best practices, so is it possible to do it with this abp framework and how should I do it?

Thank you.


1 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Use MVC HTTP attributes. You need to add Microsoft.AspNetCore.Mvc.Core if you're doing this in Application project. Here's an example:

    // GET /tickets/12 - Retrieves a specific ticket
    [HttpGet("/tickets/{id:long}")]
    public async Task<TicketDto> GetTicket(long id)
    {
        // ...
    }