Reputation: 3487
I have an exmaple of mvc 4 web API , and I want to consume it in Excel 2010. whats the easiest way to do it? I am thinking to pass in the username and password as string parameter if solution need to be complicated.
[Authorize]
public class AccountBalanceApiController : ApiController
{
//http://localhost/FTAccounting/api/AccountBalanceApi?companyId=16&fiscalYear=2012
public Dictionary<int, TrialBalanceAccountSummaryModel> Get(int companyId, int fiscalYear)
{
return AccountBalance.GetTrialBalance(companyId, fiscalYear);
}
}
Update: Web service Authentication is not possible in Excel. Reference from http://cwebbbi.wordpress.com/2012/07/31/using-the-webservice-function-in-excel-2013/
Upvotes: 1
Views: 8284
Reputation: 1297
In modern Excel you can use Get & Transform to connect to Web API with authorisation. Select Data tab, then in the Get & Transform group New Query -> From Other Sources -> From Web (Note: do not confuse this with 'From Web' button which is directly in the Get External Data group). Enter your endpoint URL (you can also define request headers here) and in the next step you will be asked for authentication method.
Upvotes: -1
Reputation: 3487
web service Authentication is not possible in Excel. reference from http://cwebbbi.wordpress.com/2012/07/31/using-the-webservice-function-in-excel-2013/
Upvotes: 2