This summarises how Metrici distinguishes between REST calls and normal browser-based HTML or file access.
- If the URL includes the parameter method=rest, it is a REST call.
- If the URL includes the method parameter and it is not "rest", it is not a REST call.
- If the HTTP method is PUT, PATCH, or DELETE, it is a REST call.
- If the URL has a file extension (where the last part is not numeric), it is not a REST call, and the file is served.
- If the Accept header includes "html", "image", "css", or "javascript", it is not a REST call.
- If the Accept header includes "json" or "xml", it is a REST call.
- If the Referer header is populated, it is not a REST call.
- If there is no User-Agent header, it is a REST call.
- If the User-Agent header contains any of the values in the server-wide "htmlOnlyUserAgents" parameter, it is not a REST call. This is used to detect search engine crawlers such as Google.
- If none of the above conditions apply, it is a REST call.
To ensure the REST interface is called:
- Don't set the accept header or user-agent header.
- Don't use a file extension.
If you are making a REST call from a browser, you must force it to be a REST call, rather than retrieving the node rendered as HTML. You can do this by setting the accept header to "application/json" or "application/xml", depending on the expected return type, or by appending the query parameter method=rest.