简体   繁体   中英

How to specify an API key name in Excel - A web API key can only be specified when a web API key name is provided

I have a standard MVC API OData enabled service which works under anonymous authentication. I would like to pass a web API key to the application...which works fine when added through code or postman..

Unfortunately my users would prefer to use Excel and I can't I find anywhere in Excel to enter this data...

I've checked Fiddler and Excel is not even trying to send data to the client and I am trapped in one of the errors below.

What is a valid key in Excel and how do it enter it?

在此处输入图片说明

在此处输入图片说明

In Excel, open the Power Query Editor, and insert the code below, or adjust the default code: add ApiKeyName = "ApiKey" as part of the 3 parameter of OData.Feed.

let
    Source = OData.Feed("https://localhost/odata", null, [Implementation="2.0", ApiKeyName = "ApiKey"]),
    Table_table = Source{[Name="Table",Signature="table"]}[Data]
in
    Table_table

Now, you can use the Web API credentials dialog. Your key will be part part of the http query string that is sent to the server: ?ApiKey=abcdefg

See also authenticating with Excel Power Query against .Net Odata Web Api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM