Forum Discussion
Prompting for values in invoked function,
- 2 years ago
I have found another solution:
Solved: Re: Avoiding free text credentials in Power BI que... - Microsoft Fabric Community
Calling the creds from a slsx in a secure location, rather than entering manually.
Hi richardc1 ,
This is related with the fact that you are concatenating the "Bearer " with your GetToken
Try the following change:
let
Source = Json.Document(Web.Contents("https://instnace.service-now.com/api/now/table/incident?sysparm_limit=100", [Headers=[Authorization="Bearer "& Text.From ( GetToken) ]])),
#"Converted to Table" = Table.FromRecords({Source}),
...etc
Has you can see I have wrap the GetToken with a Text.From this will convert the result to a text string, even if it's a text string sometimes you need to do this workaround
Thanks so much for your reply.
I tried this and got error:
Embedding the GetToken query this way does not prompt for credentials, it tries to extract text from that function directly and fails.
"Expression.Error: We cannot convert a value of type Function to type Text."
I need to call for parameters first, invoke GetToken with those credentials, store the output (this bit is key, and one I don't understand), and use that output (i.e. the bearer token) in the Json call.
e.g
let
source = (id as text, secret as text, un as text, pw as text, _token as text)=>
Token = text.from(GetToken(id,secret,un,ow,_token)
in
But the syntax is wrong, gices error: "Token literal expected"
I think we are getting close!