One of the things I love working on are webservices. However, one of the things I dislike about using SOAP is that using the endpoint isn’t as nice as it could be. This is something that has been addressed by how REST endpoints are interacted with. By writing clean REST endpoints, your users can easily understand what is going on under the hood
Clean REST Endpoints
What do I mean by clean REST endpoints? Let’s take a look at two possible URIs and see which ones are cleaner and easier to understand. For the examples below, we are going to have two URIs, one to get a case by case number, and one to get it’s comments
#Get case using url parameter
curl "$SFDC_URL/services/apexrest/v1/cases?number=012345"
#Get case comments using url parameter
curl "$SFDC_URL/services/apexrest/v1/comments?number=012345"
#Get case using number in url
curl "$SFDC_URL/services/apexrest/v1/cases/012345"
#Get case comments using number in url
curl "$SFDC_URL/services/apexrest/v1/cases/012345/comments"
While the parameters are perfectly acceptable, they are not pretty. Also, it is difficult as a programmer to know if the param you have add to the URI is number, or casenumber or what. So instead if we have clean REST endpoints, we have the case number as part of the URI and it is just more logical as to knowing how to get a specific case.