Forum Discussion
Data source accessing a web URL which requires Authentication headers
- Anonymous8 years ago
Thank you. I have now managed to spend some more time on this.
I can confirm that the suggested work-around to use the RelativePath parameter solves the problem.
I do not need to use static values for my Authorization parameters, which is good, because I don't want to have to duplicate these across many queries. This is the query which now works for me.
Source = Json.Document(Web.Contents("https://api.harvestapp.com/", [ RelativePath="v2/time_entries", Query=[from=DateThreshold], Headers=[Authorization="Bearer " & HarvestAccessToken, #"Harvest-Account-ID"=HarvestAccountId, #"User-Agent"="PowerBI_DBRetrieval (" & HarvestUserEmail & ")"]] )),The important point, for this API, is that the root URL is not authenticated, so this passes the credentials check. When the real query is executed, the RelativePath, Query, and Headers are all correctly processed.
Anonymous,
Provide static values for these parameters(Authorization, User-Agent,etc) in your Headers, and combine RelativePath and Query option in your code. For more details, please review abedkhooli's reply in the following similar thread.
https://community.powerbi.com/t5/Service/Refreshing-a-Restful-Data-Source-with-API-Key/td-p/131298
Regards,
Lydia
Thank you. I have now managed to spend some more time on this.
I can confirm that the suggested work-around to use the RelativePath parameter solves the problem.
I do not need to use static values for my Authorization parameters, which is good, because I don't want to have to duplicate these across many queries. This is the query which now works for me.
Source = Json.Document(Web.Contents("https://api.harvestapp.com/",
[
RelativePath="v2/time_entries",
Query=[from=DateThreshold],
Headers=[Authorization="Bearer " & HarvestAccessToken, #"Harvest-Account-ID"=HarvestAccountId, #"User-Agent"="PowerBI_DBRetrieval (" & HarvestUserEmail & ")"]]
)),The important point, for this API, is that the root URL is not authenticated, so this passes the credentials check. When the real query is executed, the RelativePath, Query, and Headers are all correctly processed.