For Dynamics CRM version 8.2 or below, do this:
var apiVersion = Xrm.Page.context.getVersion();
For Dynamics CRM version 9 or above, do this:
var apiVersion = Xrm.Utility.getGlobalContext().getVersion();
It will give you an expanded version which includes minor and major versions. Now, all you have to do is crop the number to get only initial numbers such as 9.1 in this case:
var shortVersion= apiVersion.substring(3, myStr.indexOf(“.”) -1);
then finally use it in your request as:
Hope this helps!