Base Project Spring 3.0
Exaples of the acess - API localhost
Method create - POST
Content-Type = application/json
URL: localhost:8080/api/persons
Body:
{
"name": "Marian Lemans",
"email": "[email protected]",
"birthDate": "1997-09-23",
"gender": {
"description": "Male"
},
"address": {
"street": "Street Teste",
"district": "District Teste",
"number": 123
}
}
Return:
{
"id": 2,
"name": "Marian Lemans",
"email": "[email protected]",
"birthDate": "1997-09-23",
"gender": {
"description": "Male"
},
"address": {
"id": 2,
"street": "Street Teste",
"district": "District Teste",
"number": 123
}
}
Method update - PUT
Content-Type = application/json
URL: localhost:8080/api/persons
Body:
{
"id": 2,
"name": "Marian Lemans",
"email": "[email protected]",
"birthDate": "1997-09-23",
"gender": {
"description": "Male"
},
"address": {
"id": 2,
"street": "Street Teste",
"district": "District Teste",
"number": 123
}
}
Return:
{
"id": 2,
"name": "Marian Lemans",
"email": "[email protected]",
"birthDate": "1997-09-23",
"gender": {
"description": "Male"
},
"address": {
"id": 2,
"street": "Street Teste",
"district": "District Teste",
"number": 123
}
}
Method get all pageable - GET
URL: http://localhost:8080/api/persons/0/10
Return:
{
"content": [
{
"id": 8,
"name": "Martina",
"email": "[email protected]",
"birthDate": "2022-02-16",
"gender": {
"description": "Female"
},
"address": {
"id": 8,
"street": "Street Teste",
"district": "District Teste yyyy",
"number": 34
}
},
{
"id": 9,
"name": "Denis Rodman",
"email": "[email protected]",
"birthDate": "2022-02-02",
"gender": {
"description": "Male"
},
"address": {
"id": 9,
"street": "Street Test 4",
"district": "District Teste",
"number": 67
}
},
{
"id": 10,
"name": "Robbin William",
"email": "[email protected]",
"birthDate": "2022-02-07",
"gender": {
"description": "Male"
},
"address": {
"id": 10,
"street": "Street Test 4",
"district": "District Teste yyyy",
"number": 56
}
},
{
"id": 2,
"name": "Marian Lemans",
"email": "[email protected]",
"birthDate": "1997-09-23",
"gender": {
"description": "Male"
},
"address": {
"id": 1,
"street": "Street Teste",
"district": "District Teste",
"number": 123
}
}
],
"pageable": {
"sort": {
"empty": true,
"sorted": false,
"unsorted": true
},
"offset": 0,
"pageSize": 10,
"pageNumber": 0,
"paged": true,
"unpaged": false
},
"totalPages": 1,
"totalElements": 4,
"last": true,
"size": 10,
"number": 0,
"sort": {
"empty": true,
"sorted": false,
"unsorted": true
},
"first": true,
"numberOfElements": 4,
"empty": false
}
Method get all pageable with word search - GET
URL: http://localhost:8080/api/persons/0/10/de
Return:
{
"content": [
{
"id": 9,
"name": "Denis Rodman",
"email": "[email protected]",
"birthDate": "2022-02-02",
"gender": {
"description": "Male"
},
"address": {
"id": 9,
"street": "Street Test 4",
"district": "District Teste",
"number": 67
}
}
],
"pageable": {
"sort": {
"empty": true,
"sorted": false,
"unsorted": true
},
"offset": 0,
"pageSize": 10,
"pageNumber": 0,
"paged": true,
"unpaged": false
},
"totalPages": 1,
"totalElements": 1,
"last": true,
"size": 10,
"number": 0,
"sort": {
"empty": true,
"sorted": false,
"unsorted": true
},
"first": true,
"numberOfElements": 1,
"empty": false
}
Method get one - GET
URL: localhost:8080/api/persons/2
Return:
{
"id": 2,
"name": "Marian Lemans",
"email": "[email protected]",
"birthDate": "1997-09-23",
"gender": {
"description": "Female"
},
"address": {
"id": 1,
"street": "Street Teste",
"district": "District Teste",
"number": 123
}
}
Method delete - DELETE
URL: localhost:8080/api/persons/1
Return: No content