I am working on a gateway project. Several devices gets connected on communication bus of this gateway.
URI ‘[GET] /devices’ gets list of devices.
List of devices is populated by scanning the bus. As scanning is a time consuming operation list is cached in gateway. Normally users access cached information.
But user has an option to get list of devices by forcing a scan. Please suggest me correct REST style representation for scanning. I could think of following options
1) ‘[GET] /devices/scan’
2) ‘[GET] /devices’ with payload as {“action” : “scan”}
I am not so convinced with option1, as ‘scan’ is an action, thinking it as a resource is not making sense.
And with option2 I will end up having a payload to parse.
What is the correct way of representing scan scenario?
You can make it a query parameter as in
GET /devices?scan=1. You can’t have any payload in the content with a GET. You’d have to use a POST.