Odata feed无法在PowerBI或Excel中连接

时间:2019-03-12 16:12:10

标签: asp.net excel odata powerbi

我在asp.net Web API应用程序中有一个OData feed设置。该应用程序使用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();
        }
    }

0 个答案:

没有答案