Pulling BAQ into Excel - Web API, OData, JSON?

I have created an API and set its scope to just the BAQ I want to return. In the REST helper, I can paste the API in the header for REST v2. I get the data back as expected in the REST helper. However, I want to use this data in Excel to make some charts. I have tried a few different ways to pull it in, including power query editor, and the =webservice formula. Nothing has worked so far. I couldn’t get the power query editor to return anything, and the webservice formula always returned #Value.

I did a little searching and found this post that sounds like bad news for my case:
Issues with REST BAQ - Experts’ Corner - Epicor User Help Forum (epiusers.help)

So is there a solution? Is there a way to pull BAQ data from a REST v2 API into Excel? What is the process? If I use PowerQuery Editor, what is the code to put in there. It kept saying that I need an API key name. My key name is OJEXKey, and my BAQ is named OJEXForDash. Every time I tried to put it in someplace, it wouldn’t accept it. Similar to this issue:
asp.net mvc - 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 - Stack Overflow
This is my request URL:

https://centralusdtapp01.epicorsaas.com/saas512/api/v2/odata/VTAERO/BaqSvc/OJEXForDash/Data

Help me understand the differences here. I think I want to use web API as the data source, not OData. But sometimes it looks like web API and odata are the same thing. I think both methods return data in JSON format. Am I getting these acronyms correct? I want to connect to the datasource using only my API key, so I don’t have to enter my username and credentials. Is that how this works?
Thanks for your time!
Nate

Do you get the same issue when using Odata?

I can’t explain the difference between the two data connection types Nate, but what happens when you try to use Odata/From Web option?

I went to Excel > Data > Get Data > From Other Sources > From Odata Feed…
Left it at basic and pasted my URL: https://centralusdtapp01.epicorsaas.com/saas512/api/v2/odata/VTAERO/BaqSvc/OJEXForDash/Data

Unable to connect We encountered an error while trying to connect. Details: "Access to the resource is forbidden."
Retry, Edit, Close

It never asks for my API key with this method.

I went into manage data sources and deleted all my old global permissions that were leftover from me trying and failing to get this to work.

In this window I can’t get it accept the API key.

If I have to add the api key name, what is the syntax for that?
Also, should I choose the “level” that include my BAQ name and /Data at the end?

Try adding the ‘?api-key=x’ parameter to your query URL.

https://{domain}/{appServer}/api/v2/odata/{company}/BaqSvc/{baqName}/Data?api-key={apiKey}

For OData feeds use Basic authentication. It is an Epicor u/p.

I am trying to get away from using the odata v1 with username/pw authentication. Thats the whole reason the API key exists in the first place. Right?

I tried adding this to the connection but still get the same errors. Either anon connection is not allowed, or I have to enter an API key, which keeps saying I need an API key name. Also tried the whole website string with the api key in Excel’s -webservice() formula, but still returns nothing (value).

The only way I have ever gotten this to work is to get data “From Web” instead of “From oData Feed” in Excel. Using the oData Feed always gave me an error.


I get the same kind of error using the web data source in excel. What do you paste in there as a connection string? Do you include your API in the address? Do you include the API key name in the address?

I just pasted the url with the API key at the end of it into the ‘Basic’ From Web option, e.g.

https://[domain]/[server]/api/v2/odata/[company]/BaqSvc/[BAQName]/Data?api-key=[API Key]

1 Like

After you enter that, the next window asks for a way to authenticate. It won’t accept anonymous and using basic forces you to enter a username and pw. I thought the whole point of API key and v2 REST was to avoid the username requirement? If I choose WebAPI, I am back to where I started.

Excel edits URLs and strips away all query strings. You have to use REST v1.

2 Likes

So what is rest v2 for? Why have API keys? Will v2 still work for other applications (say Grafana?).

In the couple of worksheets I have done, once a user opens the file and refreshes the data, they enter their credentials for the first time it no longer asks them to authenticate. Depending on what you’re trying to do that might be a deal breaker, but unfortunately it’s the only way I know how to get this to work in the first place.

1 Like

idk, does grafana changes URL unconditionally?

IDK either. Hoping to get grafana setup now that excel is out of the question.

another option if it allows custom headers.
It is not MS product, so hopefully it does not need to dictate how OData URL should look like

1 Like

Nate, are you trying any of the following:

Handling authentication for Power Query connectors - Power Query | Microsoft Learn

No I haven’t. How would you use the syntax they gave with the values I have?