I am receiving Status code 0 when sent request from C#. But when I send the same request from Postman, I get status code 200.
Can you some help me, where it's going wrong?
RestClient restClient = new RestClient("http://data.melbourne.vic.gov.au/");
var request = new RestRequest(BaseAddress + "resource/afpd-eane?spot_id=9747", Method.GET);
request.AddHeader("X-App-Token", Token);
request.AddHeader("Content-Type", "application/json; charset=utf-8");
var resp = restClient.Execute(request);
Response: StatusCode: 0, Content-Type: , Content-Length: 0 "The underlying connection was closed: An unexpected error occurred on a send."}
You've used BaseAddress
when calling RestRequest
constructor. That's redundant - base adress was passed to RestClient
already. See the correct variant:
var request = new RestRequest("resource/afpd-eane?spot_id=9747", Method.GET);