Just thought I'd drop a handy little piece of code for when you're running / debugging the OrderCloud .NET SDK locally. If you ever need to see which HTTP calls are being made, and any info about the request URL, body, response, or more importantly errors, you can just add this little snippet to your Program.cs
after var app = builder.Build();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FlurlHttp.Configure(settings => settings.BeforeCall = (FlurlCall call) => | |
{ | |
app.Logger.LogInformation($"Calling {call.Request.Url} with {call.RequestBody}"); | |
}); | |
FlurlHttp.Configure(settings => settings.OnError = (FlurlCall call) => | |
{ | |
app.Logger.LogError(call.Exception, $"Error calling {call.Request.Url}"); | |
}); |
Hope this helps someone! Enjoy :)