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

ghd258 picture ghd258  路  6Comments

weswitt picture weswitt  路  3Comments

Taher-Assad picture Taher-Assad  路  5Comments

mwinder picture mwinder  路  7Comments

instriker picture instriker  路  7Comments