Forum Discussion
megel
4 years agoRegular Visitor
Setup Web Credentials for Application Insights by API
Hi All, I want to setup the Web Credentials for my Dataset by API from a service: The Datasource is an Application Insights component. To do this manual, I have to use my organizational...
Anonymous
4 years agoNot applicable
HI megel,
You can try to use the following M query code if help with your scenario:
let
secretId = xxxxx,
authKey = "Basic " & secretId,
url = "https://api.xxxxx.com/oauth2/token",
GetJson =
Web.Contents(
url,
[
Headers = [
#"Authorization" = authKey,
#"Content-Type" = "application/x-www-form-urlencoded;charset=UTF-8"
],
Content = Text.ToBinary("grant_type=client_credentials")
]
),
token = Json.Document(GetJson)[access_token],
Result =
Web.Contents(
"https://xxxxx.xxx.com",
[
Headers = [
#"Content-Type" = "application/json",
Authorization = "Bearer " + token
],
RelativePath = "/xxxxx/xxxxx"
]
)
in
Result
Regards,
Xiaoxin Sheng