When to use Query Parameter and when to use matrix parameter?
The parameters in a URI can either be query parameter or matrix parameters. There are many advantages of matrix parameter over query parameter: -
1) Matrix parameters are considered to be part of URI by proxies which allow it to be cached whereas URI's with "?" i.e query parameters are not cached.
2) Matrix parameters can be used at any point in the URI which makes it possible to set parameters where they are needed instead of appending all at the end.
3) Matrix parameters can occur with different sub-resources with different values in same URI
For example: - http://localhost/category;name=abc/article;name=xyz
Which of the HTTP methods are safe methods in REST Webservice?
GET, HEAD and OPTIONS are called as safe methods because issuing these requests does not change the state of the server(do not modify resources).
Safe methods are methods that can be cached, prefetched without any repercussions to the resource.
What are HTTP idempotent methods?
An idempotent HTTP method is a method that can be called many times without different outcomes. It does not matter if the method is called only once, or many times, the result is same.
Below are the list of idempotent methods:
How to delete resources using REST API ? Can we use GET/POST to delete resources, if not why?
We can use DELETE method of HTTP/HTTPS protocol to delete the resources using REST API. We cannot use POST/GET methods to delete the resources as it creates confusion ,because GET method is normally used to fetch data and POST method is normally used to submit the data and create new resources, and further if the url is mistakenly exposed as simple links to any bot/crawler it will simply delete the resources.
Describe some of the features of RESTful web service.
What is conditional GET method?
Using Conditional GET client asks a server if a resource has changed, if the resource state has changed then server responds back with resource else server replies with 304 Not Modified response, rather than the resource itself.
Any GET request is conditional if it uses "If-None-Match" header with the ETag set as the value or "If-Modified-Since". If the resource state changes subsequently ETag gets changed and the server responds with the resource.