diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index 8f4f6d8345..846beaa056 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -109,7 +109,15 @@ protected virtual HttpRequestMessage BuildRequestMessage(IRequest request) HttpRequestMessage requestMessage = null; try { - var fullUri = new Uri(request.BaseAddress, request.Endpoint); + // Remove any leading slash from endpoint Uri (otherwise it clobbers the /api/v3/ in BaseAddress) + var endpoint = request.Endpoint; + if (!endpoint.IsAbsoluteUri && + endpoint.ToString().StartsWith("/", StringComparison.OrdinalIgnoreCase)) + { + endpoint = new Uri(endpoint.ToString().TrimStart('/'), UriKind.Relative); + } + + var fullUri = new Uri(request.BaseAddress, endpoint); requestMessage = new HttpRequestMessage(request.Method, fullUri); foreach (var header in request.Headers)