|
7 | 7 | using System.Management.Automation;
|
8 | 8 | using System.Net;
|
9 | 9 | using System.Net.Http;
|
10 |
| -using System.Text; |
11 | 10 | using System.Text.Json;
|
12 | 11 | using System.Text.Json.Serialization;
|
13 | 12 | using System.Threading;
|
@@ -215,7 +214,7 @@ public IEnumerable<T> GetResultCollection<T>(string url, bool camlCasePolicy = t
|
215 | 214 | var results = new List<T>();
|
216 | 215 | var request = Get<RestResultCollection<T>>(url, camlCasePolicy, propertyNameCaseInsensitive, additionalHeaders);
|
217 | 216 |
|
218 |
| - if (request.Items.Any()) |
| 217 | + if (request != null && request.Items.Any()) |
219 | 218 | {
|
220 | 219 | results.AddRange(request.Items);
|
221 | 220 | while (!string.IsNullOrEmpty(request.NextLink))
|
@@ -264,7 +263,7 @@ public T Get<T>(string url, bool camlCasePolicy = true, bool propertyNameCaseIns
|
264 | 263 | }
|
265 | 264 | catch (Exception e)
|
266 | 265 | {
|
267 |
| - LogError($"Failed to parse response from server. Error message: '{e.Message}'. Received content: '{stringContent}'. Model type to parse it to: '{typeof(T)}'."); |
| 266 | + LogError($"Failed to parse response from server. Error message: '{e.Message}'. Model type to parse it to: '{typeof(T)}'."); |
268 | 267 | //Cmdlet.LogWarning($"Failed to parse response from server. Error message: '{e.Message}'. Received content: '{stringContent}'. Model type to parse it to: '{typeof(T)}'.");
|
269 | 268 | return default;
|
270 | 269 | }
|
@@ -311,7 +310,7 @@ public T Delete<T>(Cmdlet cmdlet, PnPConnection connection, string url, bool cam
|
311 | 310 |
|
312 | 311 | #region PATCH
|
313 | 312 | public T Patch<T>(string url, T content, IDictionary<string, string> additionalHeaders = null, bool camlCasePolicy = true)
|
314 |
| - { |
| 313 | + { |
315 | 314 | var serializerSettings = new JsonSerializerOptions() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };
|
316 | 315 | if (camlCasePolicy)
|
317 | 316 | {
|
@@ -387,7 +386,7 @@ private void PostInternal(string url, HttpContent content, IDictionary<string, s
|
387 | 386 | {
|
388 | 387 | var message = GetMessage(url, HttpMethod.Post, content, additionalHeaders);
|
389 | 388 | GetResponseMessage(message);
|
390 |
| - } |
| 389 | + } |
391 | 390 |
|
392 | 391 | private T PostInternal<T>(string url, HttpContent content, IDictionary<string, string> additionalHeaders = null, bool propertyNameCaseInsensitive = false)
|
393 | 392 | {
|
@@ -455,7 +454,7 @@ public HttpResponseMessage Put2(string url, HttpContent content, string accessTo
|
455 | 454 | {
|
456 | 455 | var message = GetMessage2(url, accessToken, HttpMethod.Put, content, additionalHeaders);
|
457 | 456 | return GetResponseMessage2(message);
|
458 |
| - } |
| 457 | + } |
459 | 458 |
|
460 | 459 | #endregion
|
461 | 460 |
|
|
0 commit comments