I have a BAQ in Epicor with two parameters. I can call it from Postman and Swagger Help without a problem. I can also call it from Postman without a problem. But I cannot get it to work in Power Query Editor from Excel.
I have an API created and the BAQs are assigned to the scope. The scope is applied to the API. I also have an integration user account for just this purpose. I can’t figure out how to replicate my settings from Postman into Power Query Editor.
From Postman:
Setup with Basic Auth pointing to integration user account.
Also passing in API key in header:
x-api-key={{ApiKey}}
Those start and end dates are also parameters.
{{Host}}/api/v2/odata/VTAERO/BaqSvc/EarnedHours5/Data?StartDate=‘2025-02-03’&EndDate=‘2025-02-04’
In Excel Power Query Editor I have this code:
let
StartDate = Date.ToText(StartDate, "yyyy-MM-dd"),
EndDate = Date.ToText(EndDate, "yyyy-MM-dd"),
ApiKey = apikey,
// URL with API Key as query parameter
URL = "{{MyServer}}/api/v2/odata/VTAERO/BaqSvc/EarnedHours5/Data?startDate=" & StartDate & "&endDate=" & EndDate & "&ApiKey=" & ApiKey,
// Fetch data using Web.Contents
Source = Json.Document(Web.Contents(URL)),
// Assuming the returned data is a JSON array, convert it into a table
SourceTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Changed Type" = Table.TransformColumnTypes(SourceTable, {
{"LaborDtl_PayrollDate", type date},
{"Calculated_ProdEarnedHours", type number},
{"Calculated_EmpEff", type number},
{"LaborDtl_EarnedHrs", type number},
{"LaborDtl_LaborQty", type number},
{"LaborDtl_BurdenHrs", type number},
{"LaborDtl_LaborHrs", type number}
})
in
#"Changed Type"
I keep getting “Access to the resource is forbidden.” I have setup the power query data source as basic with the integration account credentials. I also tried it with just the API key. It didn’t like it either way. I must be missing something important.
I can get the data to work if I only use basic auth and use my own creds. But I don’t want to include my cred s in a file I share on the network. Instead, I want anyone that opens it to be able to update the file from Epicor with the built-in creds. I feel like I have done this once before, but I couldn’t find a solution that works.
Thanks for your time!
Nate