When i try to use the code snippet below, i get this message:
{System.NullReferenceException: RestClient must contain a value for BaseUrl
at RestSharp.RestClient.DoBuildUriValidations(IRestRequest request)
at RestSharp.RestClient.BuildUri(IRestRequest request)
at RestSharp.RestClient.ConfigureHttp(IRestRequest request)
at RestSharp.RestClient.Execute(IRestRequest request, String httpMethod, Func
3 getResponse)}`
The code i'm using is this:
var restClient = new RestClient();
var restRequest = new RestRequest("http://dawa.aws.dk/regioner", Method.GET);
IRestResponse restResponse = restClient.Execute(restRequest);
It's a public API so feel free to test the http call.
Best Regards
Bjarne
So what is your issue? The exception says it all.
If you now would try the url in a browser, you would notice that it's working - and all the other call to aws.dk is also working, but this one is not.
This is nothing to do with the URL. You have to specify the base url for the RestClient
. You should be using
var restClient = new RestClient("https://dawa.aws.dk");
var restRequest = new RestRequest("/regioner", Method.GET);
IRestResponse restResponse = restClient.Execute(restRequest);