Spring Boot Difference usages of HTTP Methods

183 Views Asked by At

I am using Spring Boot for creating rest API. I learnt about PUT, PATCH, POST. PUT is for updating the resource and if Id is not present then it creates. Patch is for updating part of the resource and Post for creating new resources.

What I don't understand is, are they are only standards that helps outside world to let all know what the API is for ? Because I can do the same implementation in Put like Patch and make Put request to perform partial updates.

1

There are 1 best solutions below

0
Mina- On

HTTP Methods are standard or specification

As you said, you can implement with totally ignoring what standard says, but it means your software/api should be used with concerns(because this don't follow standards), which make integration with others complicated.

For example, old standard says there can't be no body should be sent on GET, and Java developers followed this standard faithfully, errors occurred or were ignored when adding a body to a GET request, which made some developers in trouble who did not followed standard.

Read also: HTTP Methods definitions - RFC 9110