Forum Discussion
API Key was expected to be provided in the header for this call
I've connected my dashboard to a source as explained by the provider here and it loads the data and refreshes fine in desktop. But when I upload it and try to shcedule a refresh it gives me this error:
"Failed to update data source credentials: Web.Contents failed to get contents from 'https://interact.leadforensics.com/WebApi_v2/Business/GetAllBusinesses?datefrom=01-01-2010%2000:00:0...' (400): The Lead Forensics API Key was expected to be provided in the header for this call."
- Anonymous5 years ago
The solution to this problem was changing the M Query as below:
let vBaseUrl = "https://interact.leadforensics.com", vPath = "WebApi_v2/Visit/GetAllVisits?datefrom=01-01-2020 00:00:00&dateto=31-12-2030 23:59:59&pagesize=999999&pageno=1", vHeaders = [#"Authorization-Token"="THIS IS WHERE I PUT THE AUTH TOKEN", #"ClientID"="THIS IS WHERE I PUT THE ID"], Source = Web.Contents ( vBaseUrl, [RelativePath=vPath, Headers=vHeaders] ), Json = Json.Document ( Source ), SiteVisitList = Json[SiteVisitList], #"Converted to Table" = Table.FromList(SiteVisitList, Splitter.SplitByNothing(), null, null, ExtraValues.Error), in #"Converted to Table"
3 Replies
- lbendlinSuper User
you may have had an active session in the desktop from a prior authentication. That won't work in the service. Provide the key as indicated.
- AnonymousNot applicable
It works in desktop (and continues working), cause i set it up. No one was using this source in the company before. But just to be sure, I have cleared all existing connections and set it up again and it works in Desktop. But not in the service.
If you click on the link I provided you will see what information do they provide i.e. Authorization Token and Client ID. They don't give you the API key name and it is not required to connect to the source.
- AnonymousNot applicable
The solution to this problem was changing the M Query as below:
let vBaseUrl = "https://interact.leadforensics.com", vPath = "WebApi_v2/Visit/GetAllVisits?datefrom=01-01-2020 00:00:00&dateto=31-12-2030 23:59:59&pagesize=999999&pageno=1", vHeaders = [#"Authorization-Token"="THIS IS WHERE I PUT THE AUTH TOKEN", #"ClientID"="THIS IS WHERE I PUT THE ID"], Source = Web.Contents ( vBaseUrl, [RelativePath=vPath, Headers=vHeaders] ), Json = Json.Document ( Source ), SiteVisitList = Json[SiteVisitList], #"Converted to Table" = Table.FromList(SiteVisitList, Splitter.SplitByNothing(), null, null, ExtraValues.Error), in #"Converted to Table"