Nice and informative article. But heed this fact as well. Take your URI:
www.yourapi.com/data/savedata?name=temperature&value=32
RESTful requests are inherently resource-oriented. But this request is more like an instruction. Generally, if you’re adhering to RESTful practices, you do not specify your endpoint like the above. What you generally do is like this.
Say that you want to send name
and value
to your sensor. Usually, if you adhere to proper REST practices you should have an endpoint like /data
and a POST
request for /data
endpoint should store the data sent in the request body. (Similarly, the GET
request should also be handled by another /data
endpoint separately, in the case of retrieving data) There are generally two methods of data serialization (If you disregard new protocols like ProtoBuf) in HTTP layer: 1) XML (Old method) 2) JSON. So what you do is you set the header Content-Type
parameter of to application/json
and have {name: 'temperature', value:32}
in the POST
request body.