I try to retrieve information to Power BI by using an API token, however, my result is the token by itself instead of the final information. I don’t know, what to change in the advanced code.
Thank you for any help.
let
// Get the API Token
api_url = “https://apigtwb2c.us.dell.com/”,
grant_type = “client_credentials”,
token_path = “auth/oauth/v2/token”,
client_id = “###############################################”,
client_secret = “############################################”,
EncodedCredentials = "Basic " & Binary.ToText(Text.ToBinary(client_id & ":" & client_secret), BinaryEncoding.Base64),
Token_Response = Json.Document(Web.Contents(api_url,
[
RelativePath = token_path,
Headers = [#"Content-Type"="application/x-www-form-urlencoded",#"Authorization"=EncodedCredentials],
Content=Text.ToBinary("grant_type=client_credentials")
]
)
),
//Get the token rom the API response
token = Token_Respose[access_token],
// Query the API
path = "PROD/sbil/eapi/v5/asset-entitlements?servicetags=93YMQ53",
fields = "all",
data= Json.Document(Web.Contents(api_url,
[
RelativePath = path,
Query = [fields=fields],
Headers=[#"Authorization"="Bearer "&token,#"Content-Type"="application/json"]
]
)
)
in
Token_Response
this is the result:
enter image description here
Cindy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.