Make HTTP Requests keeps getting easier with AspNetCore. But the document doesn’t have a sample for PostAsync method, which is quite annoying. This article provides a sample for reference.
Client
This sample uses Typed clients. I have created a RequestBin to accept the post message. The tricky part is to generate a JSON string for the request. And if you need to pass a different header value for each individual request, remember to remove the header before add the new value. Otherwise, the new value will be appended to the previous value because the same HttpClient instance is shared between requests. You can use Header Propagation if the header is from the incoming request.
Extension
An interface IWeatherForecastClient can be bound to the client WeatherForecastClient at registration. To use the Polly policy, Microsoft.Extensions.Http.Polly nuget package should be installed.