I have a mail sender method in my Spring Boot app and when I defining related endpoint in the Controller, I could not be sure what is the most proper request for that.
As I do not pass any parameter and the method does not return any content, I am not sure POST or GET is suitable for this. So, which request should I use?
Premised that the choice depends on your personal opinion and habit as developer, and on the specific purpose of your application.
However, in your specific case, I would follow the below logic:
- Request is about "retrieving" email -> GET method is better
- Request is about "sending" email -> PUT method is better
So the logic is the following: as long as I ask the server to only "retrieve" information and I am not going to send any information to the server (i.e: coming from a form), i will always use GET.
On the other hand, when you also need to pass info to the server and it needs to apply some logic/operation, which might also affect some database, in that case the POST method works better.
Hope that answer your questions. Feel free to add more details, I will strive to help you further.