Skip to content

Provided HttpClient base urls #8

@bbowyersmyth

Description

@bbowyersmyth

Porting some code from Simple.OData.Client and having some issues with where to set the base url.

Only on the required ODataClientOptions object - Invalid request Uri exception

		var baseUrl = "https://services.odata.org/V4/Northwind/Northwind.svc";
		using var httpClient = new HttpClient();

		using var client = new ODataClient(new ODataClientOptions
		{ 
			BaseUrl = baseUrl,
			HttpClient = httpClient
		});

		var metadata = await client.GetMetadataAsync(cancellationToken: CancellationToken);

On both - Resource not found $metadata exception. (Works if the url ends in a slash)

		var baseUrl = "https://services.odata.org/V4/Northwind/Northwind.svc";
		using var httpClient = new HttpClient();
		httpClient.BaseAddress = new Uri(baseUrl);

		using var client = new ODataClient(new ODataClientOptions
		{ 
			BaseUrl = baseUrl,
			HttpClient = httpClient
		});

		var metadata = await client.GetMetadataAsync(cancellationToken: CancellationToken);

No httpclient provided - Works

		var baseUrl = "https://services.odata.org/V4/Northwind/Northwind.svc";

		using var client = new ODataClient(new ODataClientOptions
		{ 
			BaseUrl = baseUrl
		});

		// Act
		var metadata = await client.GetMetadataAsync(cancellationToken: CancellationToken);

If its a required property on ODataClientOptions it doesn't feel like HttpClient should need any configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions