|
23 | 23 | SDK = { __namespace: true };
|
24 | 24 | };
|
25 | 25 | SDK.SOAP = {
|
| 26 | + getVersionSpecificWebApiUrl: function () { |
| 27 | + var serverBuildVersion = new BuildVersion(8, 0, 0, 0); |
| 28 | + |
| 29 | + //get the org version |
| 30 | + this.getCrmOrgDBVersion( |
| 31 | + onSuccess = function (serverVersion) { |
| 32 | + serverBuildVersion = serverVersion; |
| 33 | + }, |
| 34 | + onError = function (error) {}); |
| 35 | + |
| 36 | + if (serverBuildVersion.major >= 9 && serverBuildVersion.minor >= 1) { |
| 37 | + return "/api/data/v9.1"; |
| 38 | + } |
| 39 | + if (serverBuildVersion.major == 9 && serverBuildVersion.minor == 0) { |
| 40 | + return "/api/data/v9.0"; |
| 41 | + } |
| 42 | + else { |
| 43 | + return "/api/data/v8.0"; |
| 44 | + } |
| 45 | + }, |
26 | 46 | getCrmOrgDBVersion: function (successCallback, errorCallback) {
|
27 | 47 | ///<summary>Async retrieves the newest version from CRM's about.aspx page</summary>
|
28 | 48 | ///<param name="successCallback" Type="Function(BuildVersion)">The function to perform when an successfult response is returned.
|
|
105 | 125 | type: "GET",
|
106 | 126 | contentType: "application/json; charset=utf-8",
|
107 | 127 | datatype: "json",
|
108 |
| - url: rootUrl + "/api/data/v8.0/organizations", |
| 128 | + url: rootUrl + this.getVersionSpecificWebApiUrl() + "/organizations", |
109 | 129 | data: null,
|
110 | 130 | beforeSend: function (XMLHttpRequest) {
|
111 | 131 | //Specifying this header ensures that the results will be returned as JSON.
|
|
131 | 151 | contentType: "application/json; charset=utf-8",
|
132 | 152 | datatype: "json",
|
133 | 153 | //method: "MERGE", //not working on some IE/JQUERY versions
|
134 |
| - url: rootUrl + "/api/data/v8.0/organizations" + "(" + organizationId + ")", |
| 154 | + url: rootUrl + this.getVersionSpecificWebApiUrl() + "/organizations" + "(" + organizationId + ")", |
135 | 155 | data: oJSON.stringify({ orgdborgsettings: orgDbOrgSettingXml }),
|
136 | 156 | beforeSend: function (XMLHttpRequest) {
|
137 | 157 | XMLHttpRequest.setRequestHeader("Accept", "application/json");
|
|
173 | 193 | type: "PATCH",
|
174 | 194 | contentType: "application/json; charset=utf-8",
|
175 | 195 | datatype: "json",
|
176 |
| - url: rootUrl + "/api/data/v8.0/organizations" + "(" + organizationId + ")", |
| 196 | + url: rootUrl + this.getVersionSpecificWebApiUrl() + "/organizations" + "(" + organizationId + ")", |
177 | 197 | data: oJSON.stringify(update),
|
178 | 198 | beforeSend: function (XMLHttpRequest) {
|
179 | 199 | XMLHttpRequest.setRequestHeader("Accept", "application/json");
|
|
203 | 223 | type: "PATCH",
|
204 | 224 | contentType: "application/json; charset=utf-8",
|
205 | 225 | datatype: "json",
|
206 |
| - url: rootUrl + "/api/data/v8.0/organizations" + "(" + organizationId + ")", |
| 226 | + url: rootUrl + this.getVersionSpecificWebApiUrl() + "/organizations" + "(" + organizationId + ")", |
207 | 227 | data: oJSON.stringify(update),
|
208 | 228 | beforeSend: function (XMLHttpRequest) {
|
209 | 229 | XMLHttpRequest.setRequestHeader("Accept", "application/json");
|
|
223 | 243 | type: "GET",
|
224 | 244 | contentType: "application/json; charset=utf-8",
|
225 | 245 | datatype: "json",
|
226 |
| - url: rootUrl + "/api/data/v8.0/solutions?$select=modifiedon,uniquename,organizationid,ismanaged,publisherid,version,versionnumber&$filter=uniquename eq 'OrganizationSettingsEditor'", |
| 246 | + url: rootUrl + this.getVersionSpecificWebApiUrl() +"/solutions?$select=modifiedon,uniquename,organizationid,ismanaged,publisherid,version,versionnumber&$filter=uniquename eq 'OrganizationSettingsEditor'", |
227 | 247 | data: null,
|
228 | 248 | beforeSend: function (XMLHttpRequest) {
|
229 | 249 | //Specifying this header ensures that the results will be returned as JSON.
|
|
0 commit comments