Forum Discussion
Get data using web API to Power BI - Token Prefix Missing
Here is an example code I made for one API, the challenge I think is to understand what the API wants in the Headers and Body information.
This is first step to get the Token, then you will need to use the token in a second call to the API where you GET the data you want.
let
urlLogin="???",
//Body information with credential in this case
body = "{
""License"": ""??"",
""UserName"": ""??"",
""Password"": ""??"",
}",
//Create a JSON request to past to API
Parsed_JSON = Json.Document(body),
BuildQueryString = Uri.BuildQueryString(Parsed_JSON),
//Send and recive a replay inclusive the Access token.
GetTokenRecord = Json.Document(Web.Contents(urlLogin,[Headers = [#"Content-Type"="application/json",#"Accept"= "application/json"], Content = Text.ToBinary(BuildQueryString)])),
// Pick the token from the record, in this case the record was called Token in the table from the API.
token = GetTokenRecord[Token],
// Create the access token with Bearer in front if needed
access_token = "Bearer "&token,
in
access_token