Restsharp: RestClient must contain a value for BaseUr

Created on 15 Jun 2018  路  3Comments  路  Source: restsharp/RestSharp

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, Func3 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

All 3 comments

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);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

stricq picture stricq  路  6Comments

captnrob picture captnrob  路  3Comments

vDeggial picture vDeggial  路  6Comments

wojciechrak picture wojciechrak  路  3Comments

DuBistKomisch picture DuBistKomisch  路  6Comments