-
-
Notifications
You must be signed in to change notification settings - Fork 746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] When response deserialization fails, Content is null in ApiException #1384
Comments
I've found the source of bug: ApiException.cs, line 132:
Anyone knows how to fix it? |
So, any solutions now? |
Hi, were you able to figure out a solution to this problem? |
I just ran into this myself -- I found a stopgap solution in the interim while Dwolla gets around to resolving this which unfortunately judging by the timestamps on comments on this thread could be awhile. 😞 I just manually deserialize the RawContent property into the expected type myself. The below example is utilizing Newtonsoft.Json for the deserialization and Dwolla.Client v6.0.0:
|
I think I have a solution to this: if we force the diff --git a/Refit/RequestBuilderImplementation.cs b/Refit/RequestBuilderImplementation.cs
index 20092b5..2ed7c62 100644
--- a/Refit/RequestBuilderImplementation.cs
+++ b/Refit/RequestBuilderImplementation.cs
@@ -337,6 +337,7 @@ object itemValue
.SendAsync(rq, HttpCompletionOption.ResponseHeadersRead, ct)
.ConfigureAwait(false);
content = resp.Content ?? new StringContent(string.Empty);
+ await content.LoadIntoBufferAsync().ConfigureAwait(false);
Exception? e = null;
disposeResponse = restMethod.ShouldDisposeResponse; I've tried this out on the project I'm currently working on, and I'm now getting the content coming through in the |
Just to note I've moved the |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Describe the bug
When Refit can't deserialize response from api, ApiException is thrown. Unfortunately, Content property is always null, but it should be populated with the response content, that can't be deserialized.
Steps To Reproduce
Reproduction with simple XUnit test (api can be arbitrary, here I've used first public api I've found):
Expected behavior
When deserialization fails, Content property should be populated with response content.
Environment
The text was updated successfully, but these errors were encountered: