Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Dear PowerBi community
I have the following problem. My experience in API's is quite devil.
My current problem is how can I connect JWT API's through PowerBi.
I have the following data;
(The documentation of API usage--> https://automation.trendmicro.com/apex-central/api )
| Application name: | |
| Application ID: | XXXXXX-XXXX-4F8A-XXXXX-XXXXXD5BE6 |
| API key: | XXXXXX-4A7B-XXXXX-81C9-XXXXXE58623D |
| API type: | Isolate/Restore endpoint connections |
| Communication time-out: | 120 S. |
I have tried the following scripts and have not achieved positive results.
let
GetJson = Web.Contents("https://mydomain.co.uk/api/token",
[
Headers = [#"Content-Type"="application/x-www-form-urlencoded"],
Content = Text.ToBinary("grant_type=password&username=" &Username&"&password="&Password&"&clienttype=User")
]
),
FormatAsJson = Json.Document(GetJson),
#"Converted to Table" = Record.ToTable(FormatAsJson),
access_token = #"Converted to Table"{0}[Value]
in
access_tokenlet
//URLs
api_url = "", //Insert your API endpoint
token_url ="", //Insert your token URL
//Client credentials
client_credentials = "grant_type=" &grant_type& "&username=" &username& "&password="&password&"&clienttype=User",
//Get JSON Web Token via API
EncodedCredentials = "Basic "& Binary.ToText(Text.ToBinary(client_id & ":" & client_secret), BinaryEncoding.Base64),
Token_Response = Web.Contents(token_url, [Headers=
[Authorization=EncodedCredentials, #"Content-Type"="application/x-www-form-urlencoded;charset=UTF-8"],
Content=Text.ToBinary(client_credentials)]),
//Get Access Token and Token Type
FormatAsJson = Json.Document(Token_Response),
TypeToken = FormatAsJson[token_type],
AccessToken = FormatAsJson[access_token],
//Format Token
AccessTokenHeader = TypeToken & " " & AccessToken,
//Get Data
GetJsonQueryAPI = Csv.Document(Web.Contents(api_url, [Headers=[Authorization=AccessTokenHeader]]),[Delimiter=";",
Encoding=1252, QuoteStyle=QuoteStyle.None])
in
GetJsonQueryAPI
I am grateful for any help.
did you manage to find a solution?
Troubleshoot it step by step. First make sure that you can reliably get a bearer token. Then check the token at jwt.io to make sure it has the right scope. Only then continue with your attempt to retrieve data.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 46 | |
| 31 | |
| 29 | |
| 15 | |
| 15 |
| User | Count |
|---|---|
| 60 | |
| 57 | |
| 38 | |
| 23 | |
| 21 |