-
-
Notifications
You must be signed in to change notification settings - Fork 747
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
Refit.ApiException : Response status code does not indicate success: 500 (Internal Server Error) #1122
Comments
I suspect this is probably down to the default json serialization being changed from Newtonsoft to System.Text.Json as the json produced by both is slightly different, and can require some adjustments. Alternatively, you can tell Refit to use Newtonsoft to serialize the json. You could probably confirm if that's the case by simply switching it and trying again. Probably worth logging the request being made to check the actual JSON it is outputting as there's likely some things you can do to make System.Text.Json produce the output you need and have it work correctly. See the docs here for more info: https://github.com/reactiveui/refit#breaking-changes-in-6x
|
Like @james-s-tayler said, I update a project from 3.1 to 5.0 few days ago and i had to change some that was on response object from GET call but maybe you have any explicit properties named on class Produit ? |
I'm also having this issue after upgrading Refit to 6.0.x The weird thing is that if you have a custom
Then you use that handler:
It works mysteriously. Why? |
I also already set my serializer to be Newtonsoft.Json. Still the same. But that magical |
We also ran into this issue, wish I saw this sooner... Btw, we were getting this in asp.net Core 3.1 app, and then I was able to reproduce it easily in a .netcore3.1 app test project. One Post works ok, another Post method kept corrupting the payload, until added essentially empty delegating handler, that reads the request.Content, per @aiampogi . |
@omon77 are you able to provide anything like stack trace or a minimal reproduction? |
bump, still having this issue with a Xamarin Forms 5 app (Android), 500 error on POST, works fine with V5 of Refit. |
@MuddyChrisA which lib are you using for body serialization ? |
@Dashell Using Latest Refit.Newtonsoft.Json NuGet package with ContentSerializer set to NewtonsoftJsonContentSerializer. |
@MuddyChrisA and have you tried with System.Text.Json which is the default serializer in refit V6 ? when we upgrade to V6 qe got some errors with [JsonProperty("property")] from Newtonsoft because of that, but after changing for [JsonPropertyName("property")] from System.Text.Json.Serialization that works fine |
@Dashell I would like to try to migrate the serializer but it would take a lot of time, effort and testing for the project I'm working on right now, so not really an option at this time. Reverted to v5 and all works for the time being. |
any news on this? why the reading of the |
I had something very similar - My Azure function was giving a 500 error and adding the |
it works!! thanks |
Migrate to latest version 6.0.x
i always have an execption occured when using Put or Post verbs
I use console application in dotenet core 3.1 in orther to test Call Api usin Refit but without success.
the verbe GET works
here is my interface portion of code posing the probleme
[Put("/products/update/{id}")] Task update(int id,[Body] Produit produit);
and here the call of update methode
var nsAPI = RestService.For<IProductsApi>(someuri); // Update Product Produit prd = new Produit(); prd.Cb = "12345678900"; prd.Designation = "Customer Product"; await nsAPI.update(12, prd);
note that my API work fine with Postman and the Pakage RestSharp
The text was updated successfully, but these errors were encountered: