diff --git a/Source/StrongGrid/Extensions/Internal.cs b/Source/StrongGrid/Extensions/Internal.cs index b06af59b..41b93360 100644 --- a/Source/StrongGrid/Extensions/Internal.cs +++ b/Source/StrongGrid/Extensions/Internal.cs @@ -211,6 +211,17 @@ internal static string GetParameterValue(this MultipartFormDataParser parser, st /// An error occurred processing the response. internal static Task AsObject(this IResponse response, string propertyName = null, bool throwIfPropertyIsMissing = true, JsonSerializerOptions options = null) { +#if DEBUG + // This is debugging code to help me figure out which SendGrid endpoints return paging information in the 'Link' response header + var link = response.Message.Headers.GetValue("Link"); + if (!string.IsNullOrEmpty(link)) + { + var verb = response.Message.RequestMessage.Method; + var path = response.Message.RequestMessage.RequestUri.AbsolutePath.Replace("/v3/", string.Empty); + var request = $"{verb} {path}"; + throw new Exception($"The 'Link' header has been found in the response when making a request to: {request}"); + } +#endif return response.Message.Content.AsObject(propertyName, throwIfPropertyIsMissing, options); } @@ -237,6 +248,17 @@ internal static async Task AsObject(this IRequest request, string property /// An error occurred processing the response. internal static Task> AsPaginatedResponse(this IResponse response, string propertyName = null, JsonSerializerOptions options = null) { +#if DEBUG + // This is debugging code to help me figure out which SendGrid endpoints return paging information in the 'Link' response header + var link = response.Message.Headers.GetValue("Link"); + if (!string.IsNullOrEmpty(link)) + { + var verb = response.Message.RequestMessage.Method; + var path = response.Message.RequestMessage.RequestUri.AbsolutePath.Replace("/v3/", string.Empty); + var request = $"{verb} {path}"; + throw new Exception($"The 'Link' header has been found in the response when making a request to: {request}"); + } +#endif return response.Message.Content.AsPaginatedResponse(propertyName, options); }