public static HttpClient NewHttpClient(Uri uri, ICredentials creds) { HttpClient client = new HttpClient(); client.BaseAddress = uri; if (creds != null) { client.SetClientCredentials(creds); } return client; }