Forum Discussion
Refreshing a web source with an API Key and a dynamic Authorization Token fails
- 6 years ago
Hi Anonymous ,
Could you please try to verify the result if combine them into one query?
let TokenSource = Json.Document(Web.Contents("http://my.url/", [Headers=[#"x-api-key"="XXXXXXXXXXXXXXXXXXXXX"], RelativePath="the/restofmyurl"])), TokenValue = Table.FirstValue(Table.RemoveColumns(Record.ToTable(TokenSource),{"Name"})), Source = Json.Document(Web.Contents("http://my.url/", [Headers=[#"x-api-key"="XXXXXXXXXXXXXXXXXXX", Authorization="Bearer "& TokenValue], RelativePath="another/partoftheurl12345"])), #"Converted to Table" = Record.ToTable(Source), #"Expanded {0}" = Table.ExpandListColumn(#"Converted to Table", "Value"), #"Expanded {0}1" = Table.ExpandRecordColumn(#"Expanded {0}", "Value", {"nummer", "kennzeichen", "anschaffungsdatum", "vorname", "nachname", "einstellungsdatum"}, {"Value.nummer", "Value.kennzeichen", "Value.anschaffungsdatum", "Value.vorname", "Value.nachname", "Value.einstellungsdatum"}) in #"Expanded {0}1"
Best regards,
Hi Anonymous ,
Could you please try to verify the result if combine them into one query?
let
TokenSource = Json.Document(Web.Contents("http://my.url/", [Headers=[#"x-api-key"="XXXXXXXXXXXXXXXXXXXXX"], RelativePath="the/restofmyurl"])),
TokenValue = Table.FirstValue(Table.RemoveColumns(Record.ToTable(TokenSource),{"Name"})),
Source = Json.Document(Web.Contents("http://my.url/", [Headers=[#"x-api-key"="XXXXXXXXXXXXXXXXXXX", Authorization="Bearer "& TokenValue], RelativePath="another/partoftheurl12345"])),
#"Converted to Table" = Record.ToTable(Source),
#"Expanded {0}" = Table.ExpandListColumn(#"Converted to Table", "Value"),
#"Expanded {0}1" = Table.ExpandRecordColumn(#"Expanded {0}", "Value", {"nummer", "kennzeichen", "anschaffungsdatum", "vorname", "nachname", "einstellungsdatum"}, {"Value.nummer", "Value.kennzeichen", "Value.anschaffungsdatum", "Value.vorname", "Value.nachname", "Value.einstellungsdatum"})
in
#"Expanded {0}1"
Best regards,
- JirkaZ6 years agoSolution Specialist
v-lid-msft This will work in the Desktop, but not in service!
- Anonymous6 years agoNot applicable
Hi JirkaZ , did you use RelativePath and is your Base URL returning a HTTP 200 answer without an API-Key? I think otherwise it wont work. I also set the privacy level in the desktop on None and in the Service on Public.
- JirkaZ6 years agoSolution Specialist
Anonymous Yep - that's not a problem. But sometimes it won't allow you to have 2 Web.Content calls within one query and will throw an formula firewall exception, because it's not able to validate the second call. And yes - I use relative path at all times.
- Anonymous6 years agoNot applicable
Hi v-lid-msft , thank you, it now also works in the service for me.