Reputation: 21
While executing the POST or PUSH requests in Postman for the following repository (https://github.com/websharper-samples/PeopleAPI),
I am getting this error :
System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
Error Screenshot
How do I set AllowSynchronousIO to true in f# to execute POST or PUSH requests for an API?
Upvotes: 2
Views: 435
Reputation: 21
Extremely late to the party. I had this problem with Giraffe F#. Fixed it by changing
WebHostBuilder()
.UseKestrel()
.UseContentRoot(contentRoot)
.UseIISIntegration()
.UseWebRoot(webRoot)
.ConfigureAppConfiguration(Action<WebHostBuilderContext, IConfigurationBuilder> configureAppConfiguration)
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(configureServices)
.ConfigureLogging(configureLogging)
.Build()
.Run()
to
WebHostBuilder()
.UseKestrel(Action<KestrelServerOptions> configKestrel)
.UseContentRoot(contentRoot)
.UseIISIntegration()
.UseWebRoot(webRoot)
.ConfigureAppConfiguration(Action<WebHostBuilderContext, IConfigurationBuilder> configureAppConfiguration)
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(configureServices)
.ConfigureLogging(configureLogging)
.Build()
.Run()
and the configKestrel
function looks like:
let configKestrel (opts : KestrelServerOptions) =
opts.AllowSynchronousIO <- true
Upvotes: 1