I have a PowerBI Desktop query/report which is working, but when I publish this into PowerBI Service, I have problems. The service cannot properly refresh the data source due to invalid credentials.
The system is retrieving data from the Harvest web API: https://help.getharvest.com/api-v2/
This API requires extra headers to be passed; the Authorization and Harvest-Account-Id headers, as described here:
https://help.getharvest.com/api-v2/authentication-api/authentication/authentication/
I have this working in PowerBI Desktop. This is the relevant part of the query, where the header values are passed in as parameters:
Source = Json.Document(Web.Contents("https://api.harvestapp.com/v2/time_entries?from=" & DateThreshold,
[Headers=[Authorization="Bearer " & HarvestAccessToken, #"Harvest-Account-ID"=HarvestAccountId, #"User-Agent"="PowerBI_DBRetrieval (" & HarvestUserEmail & ")"]])),
This datasource is set to use 'anonymous' credentials, because none of the other types of credentials seem relevant. And I have this successfully working, and refreshing, within PowerBI Desktop.
When I publish this to Power BI Service, it can no longer refresh the data. The refresh mechanism looks at the URL and tries it, to verify the credentials, but it doesn't add the extra headers. The API is returning 404 if the extra headers are not supplied, and therefore PowerBI Service tells me that it can't validate these credentials:
Failed to update data source credentials: Web.Contents failed to get contents from
'https://api.harvestapp.com/v2/time_entries?from=2017-01-01' (404): Not Found
Is there any way I can get the refresh mechanism to use the full headers?
It does seem to do some of the URL processing? Has anyone else managed to work around a similar problem?