Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Get token and data from rest api with JWT

Hello,

I am very new to JWT and trying to get access token as well as data through JWT rest Api.

so the authentication is done through JWT token and the token should be sent in the authentication header to get the data.

here's my code for now:

 

 

 

 

let 
    //URLs
    urlApi = "https://myurl/outbound/api",
    pathToken = "/account/requesttoken",
    pathData = "/system/all",

    //Client credentials
    credentials = [ #"username" = "my_username", #"password" = "my_password" ],

    //Get JSON Web Token via API
    optionsToken = [Headers=[#"Content-Type"="application/json"], 
    Content=Json.FromValue(credentials)],
    responseToken = Web.Contents(urlApi & pathToken, optionsToken),
 
    //Get Access Token and Token Type
    responseJson = Json.Document(responseToken),
    accessToken = responseJson[token], // name of the token property
 
    //Bearer Token
    authorizationHeader = "Bearer " & accessToken,
 
    //Get Data
    optionsData = [Headers=[#"Authorization"=authorizationHeader]],
    responseData = Web.Contents(urlApi & pathData, optionsData),
    data = Json.Document(responseData)
in
    data

 

 

 

 

the error I am getting is:

 

Expression.Error: We cannot apply field access to the type Text.
Details:
Value= what appears to be the token I guess? it is alot of random letters
Key=token

 

 

I would be grateful for your help.

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

Here are some posts for your reference, 

Table.TransformColumns - Expression.Error: We cannot apply field access to the type Text. | MrExcel Message Board

Solved: Re: Expression.Error: We cannot apply field access... - Microsoft Power BI Community

Table.TransformColumns - alternative in PowerBI and PowerQuery in Excel (thebiccountant.com)

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

I'm a little confused. I don't use transform column or Replace value. So how should this help me?

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.