0

I have a .net 5.0 Blazor serverside web app that calls a .net 5 Api via Refit. When I run the app locally it works fine, but after i deploy the API and the Web app to Openshift the app loads and does the initial get fine, but if i try to update one of the records I get an error

 Error: Refit.ApiException: Response status code does not indicate success: 500 (Internal Server Error).

   at Refit.RequestBuilderImplementation.<>c__DisplayClass14_0`2.<<BuildCancellableTaskFuncForMethod>b__0>d.MoveNext() in /_/Refit/RequestBuilderImplementation.cs:line 270

--- End of stack trace from previous location where exception was thrown ---

The setup of the refit is as follows

[Patch("/MyEntity/")]

Task<bool> PatchMyEntityAsync([Body] MyEntity entity);

[Patch("/MyEntity/")]

Task<bool> PostMyEntityAsync([Body] MyEntity entity);

[Get("/MyEntity/{id}")]

Task<MyEntity> GetByIdAsync(int id);

[Get("/MyEntity/")]

Task<IEnumerable< MyEntity >> GetMyEntitiesAsync();

This all works locally but not when deployed. I am using refit version 6.0.94 When its deployed the GetMyEntitiesAsync() and GetById works but NOT the Post or Patch, locally all 4 works. When deployed i get the 500 exception. The Api is not being hit at all so refit seems to be throwing the exception

I have a list which loads fine via the API, when i click edit GetById loads the edit page fine, the strange thing is if I click the Save or even the cancel button which simply fires

NavigationManager.NavigateTo("/myEntity_list")

When the list page open again I also get the 500 error as above!

The Hosted version of the App and API are hosted on Linux Docker container. Locally where it works is Windows 10.

MicroMan
  • 1,988
  • 4
  • 32
  • 58

2 Answers2

1

I saw a similar issue here where refit 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.

https://github.com/reactiveui/refit/issues/1122

BankMan101
  • 109
  • 9
  • Thanks I tried this and no joy, It works locally and this was not an upgrade as suggested in the link.... – MicroMan Sep 27 '21 at 15:14
1

I was getting the same exception when not disposing the HttpResponse at client side. Perhaps may have a look if you forgot disposing. Everything worked fine locally and i spent a lot of time figuring this out.

Torben
  • 11
  • 1