Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Hi,
I'm trying to get a bearer token from a API so that I can refresh it to get data.
I have the following code, and it returns the token, but it also returns an error. Any idea what I'm missing?
Error:
Expression.Error: The field 'token' of the record wasn't found.
Code:
let
url = "https://myurl/authenticate",
headers = [#"Content-Type" = "application/json"],
postData = Json.FromValue([email="my@email.com",
password= "mypassword"]),
response = Web.Contents(
url,
[
Headers = headers,
Content = postData
]
),
Data=Json.Document(response),
access_token=Data[token]
in
access_token
Solved! Go to Solution.
Hi @Anonymous ,
this means that the token that you have successfully retrieved doesn't sit in the field called "token", but in a different field instead.
Please be aware that Power Query / M is case sensitive. So it might be Data[Token] instead.
Otherwise please check the exact spelling of the field name in step "Data".
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @Anonymous ,
this means that the token that you have successfully retrieved doesn't sit in the field called "token", but in a different field instead.
Please be aware that Power Query / M is case sensitive. So it might be Data[Token] instead.
Otherwise please check the exact spelling of the field name in step "Data".
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Thanks. Had to rename token to access_token 👍
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 16 | |
| 12 | |
| 9 | |
| 6 | |
| 6 |