I'm working on a C# Web API written in dotnet core. I'm struggling with the return of an action that attempts to retrieve data from a 3rd party service on another server. In the event that something goes wrong while attempting to get data from said 3rd party service, the HTTP response that made the most sense to me when looking at the spec was 502 Bad Gateway because
The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
But I can't find a way to return this in my action. IActionResult
doesn't seem to have an implementation for this code. Am I thinking this through correctly?