Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestClient must contain a value for BaseUr #1133

Closed
maximuss opened this issue Jun 15, 2018 · 3 comments
Closed

RestClient must contain a value for BaseUr #1133

maximuss opened this issue Jun 15, 2018 · 3 comments

Comments

@maximuss
Copy link

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

@alexeyzimarev
Copy link
Member

So what is your issue? The exception says it all.

@maximuss
Copy link
Author

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.

@alexeyzimarev
Copy link
Member

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants