diff --git a/config/package-solution.json b/config/package-solution.json index 7c28aed..77a63da 100644 --- a/config/package-solution.json +++ b/config/package-solution.json @@ -3,7 +3,7 @@ "solution": { "name": "expiry-indicator-client-side-solution", "id": "68bb6d2d-9895-45b4-88e8-b98835faa981", - "version": "1.0.3.0", + "version": "1.0.4.0", "includeClientSideAssets": true, "skipFeatureDeployment": false, "features": [ @@ -11,7 +11,7 @@ "title": "ExpiryIndicator command set registration", "description": "Registers ExpiryIndicator commands for modern lists and document libraries. Does not provision ExpiryDate.", "id": "913402af-ab9a-4974-9f86-5c2159ae41db", - "version": "1.0.3.0", + "version": "1.0.4.0", "assets": { "elementManifests": [ "elements.xml" diff --git a/package.json b/package.json index 330a344..f6940ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "expiry-indicator", - "version": "1.0.3", + "version": "1.0.4", "private": true, "engines": { "node": ">=6.9.0 <9.0.0" diff --git a/src/common/ExpiryConfigService.ts b/src/common/ExpiryConfigService.ts index fbdbe6a..7abd7e9 100644 --- a/src/common/ExpiryConfigService.ts +++ b/src/common/ExpiryConfigService.ts @@ -95,9 +95,7 @@ export class ExpiryConfigService { private _createConfigurationList(): Promise { const body: any = { '__metadata': { 'type': 'SP.List' }, - 'AllowContentTypes': false, 'BaseTemplate': 100, - 'ContentTypesEnabled': false, 'Description': 'Technische Konfiguration der ExpiryIndicator-App.', 'Title': CONFIGURATION_LIST_TITLE }; @@ -164,7 +162,13 @@ export class ExpiryConfigService { this._configurationListUrl(), SPHttpClient.configurations.v1, options - ).then((): void => undefined); + ).then((response: SPHttpClientResponse): Promise => { + if (!response.ok) { + return responseError(response, 'Konfigurationsliste konnte nicht ausgeblendet werden') + .then((error: Error): Promise => Promise.reject(error)); + } + return Promise.resolve(); + }); } private _getConfigurationItem(listId: string): Promise { @@ -202,7 +206,10 @@ export class ExpiryConfigService { private _headers(method?: string): any { const headers: any = { 'Accept': 'application/json;odata=verbose', - 'Content-type': 'application/json;odata=verbose' + 'Content-type': 'application/json;odata=verbose', + // SPFx 1.4.1 defaults to OData 4.0. SharePoint's verbose REST payloads + // with __metadata use OData 3.0, especially for write requests on-premises. + 'OData-Version': '3.0' }; if (method) { headers['IF-MATCH'] = '*'; @@ -211,4 +218,3 @@ export class ExpiryConfigService { return headers; } } - diff --git a/src/common/ExpiryItemService.ts b/src/common/ExpiryItemService.ts index c8797b0..a994eae 100644 --- a/src/common/ExpiryItemService.ts +++ b/src/common/ExpiryItemService.ts @@ -138,6 +138,7 @@ export class ExpiryItemService { headers: { 'Accept': 'application/json;odata=verbose', 'Content-type': 'application/json;odata=verbose', + 'OData-Version': '3.0', 'IF-MATCH': '*', 'X-HTTP-Method': 'MERGE' }, diff --git a/src/common/RestError.ts b/src/common/RestError.ts index 58c75ea..4b09a54 100644 --- a/src/common/RestError.ts +++ b/src/common/RestError.ts @@ -2,19 +2,29 @@ import { SPHttpClientResponse } from '@microsoft/sp-http'; export function responseError(response: SPHttpClientResponse, operation: string): Promise { return response.text().then((body: string): Error => { - let detail: string = body; + let detail: string = body || response.statusText || 'Unbekannter SharePoint-Fehler'; try { const parsed: any = JSON.parse(body); - detail = parsed.error && parsed.error.message ? parsed.error.message.value : body; + const payload: any = parsed.error || parsed['odata.error'] || (parsed.d && parsed.d.error); + const message: any = payload && payload.message; + if (typeof message === 'string') { + detail = message; + } else if (message && typeof message.value === 'string') { + detail = message.value; + } else if (typeof parsed.Message === 'string') { + detail = parsed.Message; + } } catch (error) { // Keep the raw response body. } - return new Error(operation + ' (' + response.status + '): ' + detail); + const correlationId: string = response.headers.get('SPRequestGuid') || + response.headers.get('request-id') || ''; + const correlationSuffix: string = correlationId ? ' [Correlation-ID: ' + correlationId + ']' : ''; + return new Error(operation + ' (' + response.status + '): ' + detail + correlationSuffix); }); } export function escapeODataString(value: string): string { return value.replace(/'/g, "''"); } - diff --git a/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.manifest.json b/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.manifest.json index 8bede9a..4a05954 100644 --- a/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.manifest.json +++ b/src/extensions/expiryIndicator/ExpiryIndicatorFieldCustomizer.manifest.json @@ -4,7 +4,7 @@ "alias": "ExpiryIndicatorFieldCustomizer", "componentType": "Extension", "extensionType": "FieldCustomizer", - "version": "1.0.3", + "version": "1.0.4", "manifestVersion": 2, "requiresCustomScript": false } diff --git a/src/extensions/expiryIndicatorCommandSet/ExpiryIndicatorCommandSet.manifest.json b/src/extensions/expiryIndicatorCommandSet/ExpiryIndicatorCommandSet.manifest.json index a2e2909..0cef668 100644 --- a/src/extensions/expiryIndicatorCommandSet/ExpiryIndicatorCommandSet.manifest.json +++ b/src/extensions/expiryIndicatorCommandSet/ExpiryIndicatorCommandSet.manifest.json @@ -4,7 +4,7 @@ "alias": "ExpiryIndicatorCommandSet", "componentType": "Extension", "extensionType": "ListViewCommandSet", - "version": "1.0.3", + "version": "1.0.4", "manifestVersion": 2, "requiresCustomScript": false, "items": {