Getting a HttpStatusCode of 0

In my case it was not a firewall issue causing the StatusCode of 0. We were using a legacy app that was still using TLS 1.0 on a server that had blocked TLS 1.0 connections. Once we enabled TLS 1.2, we got the status codes we were expecting.

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

A response code of 0 generally means that the response was empty - i.e. not even headers were returned.

This usually happens when a connection is accepted, and then closed gracefully, also known as a FIN connection. Which is where the server states that it has finished broadcasting to you, but will continue to listen for new messages. Could be a firewall issue.

Another thing to do is to change IRestResponse to RestResponse. Using IRestResponse offers no advantages in this scenario.