Part of my base url is removed upon adding a relative path

170 Views Asked by At

I have a base url https://dev.services.com/this/is/nothing/ and the path "max/status"

When I try to add "max/status" to the base url the part this/is/nothing/ is removed. This just happens some times not always.

I am doing this:

IRestClient _builder;
var baseUrl = "https://dev.services.com/this/is/nothing/";
var nextUrl = "max/status";
var fullUrl = new Uri(baseUrl, nextUrl);
var client = new _builder.Build(fullUrl);

the result should be https://dev.services.com/this/is/nothing/max/status but now is: https://dev.services.com/max/status

so, obviously I am getting an error because https://dev.services.com/this/is/nothing/max/status does not exist.

any idea?

1

There are 1 best solutions below

5
Oliver Weichhold On

Your code sample would not compile in its current form. To achieve your desired result, you'd need to change it like this:

var baseUrl = new Uri("https://dev.services.com/this/is/nothing/");
var fullUrl = new Uri(baseUrl, "max/status");