M-I5040 C-I5041(P) Applicazioni Web 1 - SUPSI - I3A - 2022/23
This API service provides a RESTful API to manage a web application that will serve as a ticket tracking platform. The service allows you to view, create, edit and delete tickets. The various requests will be made by sending the Ticket values in JSON format.
Used to get a Ticket or all Tickets.
URL : /api/tickets/<id>
Method : GET
Code : 200 OK
Content example
{
"id": 1,
"title": "Ticket 1",
"description": "Description of the ticket 1",
"author": "Pippo"
}
Condition : If the requested Ticket doesn't exist.
Code : 404 NOT FOUND
Content :
Ticket not found
Used to create a new Ticket.
URL : /api/tickets/
Method : POST
Data constraints
{
"title": "[title of the ticket]",
"description": "[description of the ticket]",
"author": "[author of the ticket]"
}
Data example
{
"title": "Ticket 1",
"description": "Description of the ticket 1",
"author": "Pippo"
}
Code : 201 CREATED
Content example
{
"id": 1,
"title": "Ticket 1",
"description": "Description of the ticket 1",
"author": "Pippo"
}
Condition : If the type of the request is not json.
Code : 400 Bad Request
Content :
Invalid content type
Used to modify an existing Ticket.
URL : /api/tickets/<id>
Method : PUT
Data constraints
{
"title": "[title of the ticket]",
"description": "[description of the ticket]",
"author": "[author of the ticket]"
}
Data example
{
"title": "Ticket 1",
"description": "Description of the ticket 1",
"author": "Pippo"
}
Code : 200 OK
Content example
{
"id": 1,
"title": "Ticket 1",
"description": "Description of the ticket 1",
"author": "Pippo"
}
Condition : If the requested Ticket doesn't exist.
Code : 404 NOT FOUND
Content :
Ticket not found
Condition : If the type of the request is not json.
Code : 400 Bad Request
Content :
Invalid content type
Used to delete an existing Ticket.
URL : /api/tickets/<id>
Method : DELETE
Code : 204 NO CONTENT
Condition : If the requested Ticket doesn't exist.
Code : 404 NOT FOUND
Content :
Ticket not found
Condition : If the type of the request is not json.
Code : 400 Bad Request
Content :
Invalid content type
Used to modify a part of an existing Ticket.
URL : /api/tickets/<id>
Method : PATCH
Data constraints (only the field/s to modify)
{
"description": "[description of the ticket]"
}
Data example
{
"title": "New Ticket"
}
Code : 200 OK
Content example (the entire Ticket, not only the modified field/s)
{
"id": 1,
"title": "New Ticket",
"description": "Description of the ticket 1",
"author": "Pippo"
}
Condition : If the requested Ticket doesn't exist.
Code : 404 NOT FOUND
Content :
Ticket not found
Condition : If the type of the request is not json.
Code : 400 Bad Request
Content :
Invalid content type