add support so using sysparm_display_value=all doesn't cause parsing exceptions during query #24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the use of sysparm_display_value=all breaks the paging logic (the logic that happens when there's more than one page in the query result) which assumes that the property value found via the 'orderByField' will be something we can append a "Z" to then DateTimeOffset.Parse.
ServiceNow.Api/ServiceNow.Api/ServiceNowClient.cs
Lines 348 to 351 in f856c47
This fails when you're using sysparm_display_value=all since the value of the orderByField will be a JObject with properties of value and display_value so you end up with an exception during the query similar to this:
String '{
"display_value": "2024-03-04 21:15:20",
"value": "2024-03-04 21:15:20"
}Z' was not recognized as a valid DateTime.
This changes the parsing to use DateTimeStyles.AssumeUniversal instead of appending a "Z" and to fall back to DateTimeOffset.MinValue for failure cases instead of throwing an exception. Since the current code throws an exception, it makes it difficult for query callers that require using sysparm_display_value=all