0

I have installed "swashbuckle" in my API project but when I try to open swagger UI page then I get the following error

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>Unable to read the entity body. The request stream has already been read in 'Bufferless' mode.</ExceptionMessage><ExceptionType>System.InvalidOperationException</ExceptionType><StackTrace>   at System.Web.Http.WebHost.HttpControllerHandler.<>c__DisplayClass18_0.<GetStreamContent>b__0()
   at System.Web.Http.WebHost.HttpControllerHandler.LazyStreamContent.get_StreamContent()
   at System.Web.Http.WebHost.HttpControllerHandler.LazyStreamContent.SerializeToStreamAsync(Stream stream, TransportContext context)
   at System.Net.Http.HttpContent.LoadIntoBufferAsync(Int64 maxBufferSize)
   at System.Net.Http.HttpContent.ReadAsStringAsync()
   at KeyNestApi.WebApiConfig.LogRequestAndResponseHandler.<SendAsync>d__1.MoveNext() in E:\Projects\KeyNest\ApiCode\Development_NewApp\KeyNestApi\App_Start\WebApiConfig.cs:line 41
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.HttpServer.<SendAsync>d__24.MoveNext()</StackTrace></Error>

My Swashbuckle version is 5.6.0 and .Net framework is 4.6.1. I am also using api versioning. Please suggest how to resolve this issue.

AMAR MATHUR
  • 46
  • 10
  • Would you mind showing us your WebApiConfig.cs especially line 41, like it says in the stacktrace? – Marco Apr 23 '19 at 05:42
  • @Marco, on line 41, I have write code for logging API request on DB. Code is `string requestBody = await request.Content.ReadAsStringAsync();` – AMAR MATHUR Apr 23 '19 at 05:51
  • Please add that file to your question. We cannot help you, if we cannot reproduce your problem – Marco Apr 23 '19 at 06:28

0 Answers0