I have a Ruby on Rails API. One of the ActionRecord models is a transaction. I want to be able to use a link such as
As I understand it, arequest should be avoided since data on the server is modified through the action. Would I then use a
GETrequest or a
POSTrequest? Is it okay if the request body is empty in the call?
To get a RESTful API, you have to squeeze everything into the CRUD paradigm. This is a well known disadvantage of REST. A non-CRUD operation is usually disguised as being a resource creation or a resource update, although it is counter-intuitive. In your case, the operation updates both the bank account and the transaction. REST does not have a specific way of updating two resources at once, so you have to choose one of the following imperfect solutions:
In case of a POST, it is allowed to have an empty body. In case of a PUT, the body represents the new version of the entire resource. In case of a PATCH, the body represents the updated part of the resource.