question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BaseUrl is now manditory

See original GitHub issue

In previous versions of RestSharp, I could call the following:

var client = new RestClient();
var request = new RestRequest("https://server.com/api/file.json", Method.Post);
client.PostAsync(request, (response, handle) => { ... });

However, this now causes an ArgumentNullException at RestSharp\RestClient.cs line 258.

Is this an expected breaking change?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

17reactions
tenbitscommented, May 2, 2018

It seems there are no way to request an endpoint just by a full URL, though RestClient has empty contrustor, but any requests afterwards with absolute uris don’t work. You must split your URL into partials.

var uri = new Uri(absoluteUrl);
var origin = uri.GetLeftPart(UriPartial.Authority);
var client = new RestSharp.RestClient(origin);
var req = new RestSharp.RestRequest(uri.PathAndQuery);

var data = client.DownloadData(req);	

Really unfriendly api.

14reactions
hallemcommented, Nov 24, 2014

Yes. The latest version converted the BaseUrl from a string to a URI and by doing so made it required to be set on the RestClient.

Read more comments on GitHub >

github_iconTop Results From Across the Web

baseURL is required for instance request · Issue #2234
When using the request() method on an instance, the request throws an error if the instance's config has url specified, but not baseUrl...
Read more >
baseURL not used in request url
1 Answer 1 · You need to ensure your .env setup has 'REACT_APP_BASE_URL' to work, if you don't have 'REACT_APP_' it won't work....
Read more >
Base URL is not working properly
I've noticed in the config panel, when I switch from 'Default Config' to 'Main Website', this is what the base URL is listed...
Read more >
The Document Base URL element - HTML - MDN Web Docs
The HTML element specifies the base URL to use for all relative URLs in a document. There can be only one element in...
Read more >
Configuration | Cypress Documentation
While it's not strictly necessary for Cypress to parse your configuration, we recommend wrapping your config object ... baseUrl: 'http://localhost:1234',
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found