首页 > 解决方案 > Odata 提要未在 PowerBI 或 Excel 中连接

问题描述

我在 asp.net web api 应用程序中有一个 OData 提要设置。该应用程序使用 Azure AD 进行身份验证,因此我计划在 PowerBI 脚本中传递不记名令牌,如下所述:

https://community.powerbi.com/t5/Desktop/Power-BI-Desktop-Unable-to-pull-from-OData-feed-using-Token/td-p/129714

通过说 Fiddler 执行此操作时,提要可以正常工作,传递不记名令牌并调用它。但是,如果我使用 PowerBi 或 excel,它会给我这个错误:

DataSource.Error: Microsoft.Mashup.Engine1.Library.Resources.HttpResource: Request failed: 
OData Version: 3 and 4, Error: The remote server returned an error: (400) Bad Request. (Bad Request)
OData Version: 4, Error: The remote server returned an error: (400) Bad Request. (Bad Request)
OData Version: 3, Error: The remote server returned an error: (400) Bad Request. (Bad Request)
Details:
    DataSourceKind=OData
    DataSourcePath=https://localhost:8401/odata/Persons

当我编辑数据源权限时,我尝试过匿名访问。我无法使用基本身份验证或组织帐户,因为它们不适用于 AzureAD。我已经使用 AllowAnonymous 设置了我的控制器,尽管我仍然在传递承载令牌并且它在 Fiddler 中工作:

    [AllowAnonymous]
    public class PersonsController : ODataController
    {

        public PersonsController()
        {
        }

        [EnableQuery(PageSize = 20, AllowedQueryOptions = AllowedQueryOptions.All)]
        public IQueryable<Persons> Get()
        {
            return new List<Persons>
            {
                new Persons
                {
                    Forename = "john",
                    Surname = "smith"
                },
                new Persons
                {
                    Forename = "john",
                    Surname = "smith"
                }
            }.AsQueryable();
        }
    }

标签: asp.netexcelodatapowerbi

解决方案


推荐阅读