From a48171ab6ac08aa145965315a978c39d07779b98 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Tue, 26 Apr 2022 03:41:30 +0200 Subject: [PATCH] Adding ability to allow for providing a custom accept header with odata=nometadata --- src/sdk/PnP.Core/Model/Base/BaseDataModel.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sdk/PnP.Core/Model/Base/BaseDataModel.cs b/src/sdk/PnP.Core/Model/Base/BaseDataModel.cs index 474d64be95..58d60301c4 100644 --- a/src/sdk/PnP.Core/Model/Base/BaseDataModel.cs +++ b/src/sdk/PnP.Core/Model/Base/BaseDataModel.cs @@ -209,13 +209,17 @@ private void ConfigureApiTypeAndRequest(ApiRequest request, out ApiType apiType, switch (request.Type) { case ApiRequestType.SPORest: - { - // Ensure external API requests keep using odata=verbose for SharePoint REST requests (see #655) + { if (request.Headers == null) { request.Headers = new Dictionary(); } - request.Headers["Accept"] = "application/json;odata=verbose"; + + // Ensure external API requests keep using odata=verbose for SharePoint REST requests unless an Accept header has explicitly been provided (see #655) + if (!request.Headers.ContainsKey("Accept")) + { + request.Headers.Add("Accept", "application/json;odata=verbose"); + } if (apiRequest != null && !apiRequest.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase)) {