Dear Dynamicweb,
I have experienced an issue with a rather old OData endpoint, where the ODataProvider fails in this method:
    private string GetMetadataURL()
    {
        if (GetEndpointResponse(ODataSourceReader.GetEndpointUrlWithTop(_endpoint.Url), out string endpointResponse, out Exception exception) != HttpStatusCode.OK || exception is not null)
            return GetMetadataURLFallBack();
        using var responseJson = JsonDocument.Parse(endpointResponse);
        if (responseJson.RootElement.ValueKind != JsonValueKind.Object)
            return GetMetadataURLFallBack();
        return responseJson.RootElement.EnumerateObject().FirstOrDefault(obj => obj.Name.Equals("@odata.context", StringComparison.OrdinalIgnoreCase)).Value.GetString() ?? GetMetadataURLFallBack();
    }
Because of a missing null check in the last part where FirstOrDefault is used. In order to get the fallback work, I have changed the last part in the method to:
    private string GetMetadataURL()
    {
        if (GetEndpointResponse(ODataSourceReader.GetEndpointUrlWithTop(_endpoint.Url), out string endpointResponse, out Exception exception) != HttpStatusCode.OK || exception is not null)
            return GetMetadataURLFallBack();
        using var responseJson = JsonDocument.Parse(endpointResponse);
        if (responseJson.RootElement.ValueKind != JsonValueKind.Object)
            return GetMetadataURLFallBack();
var parseResponse = responseJson.RootElement.EnumerateObject().FirstOrDefault(obj => obj.Name.Equals("@odata.context", StringComparison.OrdinalIgnoreCase));
        var property = responseJson.RootElement.EnumerateObject()
            .FirstOrDefault(obj => obj.Name.Equals("@odata.context", StringComparison.OrdinalIgnoreCase));
var result = property.Value.ValueKind == JsonValueKind.Undefined ? GetMetadataURLFallBack() : property.Value.GetString();
        return result;
    }
So I hope that this check can be implemented in the standard code?
Best regards, Anders