Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RestSharp get full URL of a request

Is there a way to get the full url of a RestSharp request including its resource and querystring parameters?

I.E for this request:

RestClient client = new RestClient("http://www.some_domain.com");
RestRequest request = new RestRequest("some/resource", Method.GET);
request.AddParameter("some_param_name", "some_param_value", ParameterType.QueryString);

IRestResponse<ResponseData> response = client.Execute<ResponseData>(request);

I would like to get the full request URL:

http://www.some_domain.com/some/resource?some_param_name=some_param_value
like image 391
Jaqen H'ghar Avatar asked Jan 01 '17 14:01

Jaqen H'ghar


1 Answers

To get the full URL use RestClient.BuildUri()

Specifically, in this example use client.BuildUri(request):

RestClient client = new RestClient("http://www.some_domain.com");
RestRequest request = new RestRequest("some/resource", Method.GET);
request.AddParameter("some_param_name", "some_param_value", ParameterType.QueryString);

IRestResponse<ResponseData> response = client.Execute<ResponseData>(request);

var fullUrl = client.BuildUri(request);
like image 101
Jaqen H'ghar Avatar answered Oct 19 '22 00:10

Jaqen H'ghar