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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
heriberto_mb
Frequent Visitor

PowerBI Power Query "We cannot apply field access to the type Binary"

I need a hand trying to find why I am receiving "We cannot apply field access to the type Binary "

This is the function that I've defined, I've removed the token and the directory name for security purposes:

let gettoken=() =>
    let
    JWT="<my_token>",
    Data= Web.Contents("https://api.github.com/app/installations/<id>/access_tokens", 
                      [
                        Headers=[
                                    #"Accept"="application/vnd.github+json",
                                    #"Authorization"="Bearer" & JWT,
                                    #"X-GitHub-Api-Version"="2022-11-28",
                                    #"Content-Type"="application/x-www-form-urlencoded"                                 
                        ]])
        ,token=Text.FromBinary(Json.Document(Data[token]))
in
    token   
in gettoken

No syntax errors, but when I run it...

An error occurred in the ‘get_token’ query. Expression.Error: We cannot apply field access to the type Binary.
Details:
    Value=[Binary]
    Key=token

Any help would be really appreciated.

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

What's the Text.FromBinary  for?  Not needed.

 

token=Json.Document(Data)[token]

View solution in original post

4 REPLIES 4
heriberto_mb
Frequent Visitor

It works now! Here is the adjustment I did:

let gettoken=() =>
let
JWT="<my_token>",
vContent=Text.ToBinary("{""query"": ""{   organization(login: \""github\"") { name  }}""}"),
Data= Web.Contents("https://api.github.com/app/installations/<id>/access_tokens", 
  [
Headers=[
        #"Accept"="application/vnd.github+json",
#"Authorization"="Bearer " & JWT,
#"X-GitHub-Api-Version"="2022-11-28",
#"Content-Type"="application/x-www-form-urlencoded"
    ],Content=vContent])
,token=Json.Document(Data)[token]
in
token
in gettoken

 

lbendlin
Super User
Super User

What's the Text.FromBinary  for?  Not needed.

 

token=Json.Document(Data)[token]

Thank you @lbendlin!

 

That worked, I have one more doubt...I'm getting the following error

 

An error occurred in the ‘get_token’ query. Expression.Error: The 'Authorization' header is only supported when connecting anonymously. These headers can be used with all authentication types: Accept, Accept-Charset, Accept-Encoding, Accept-Language, Cache-Control, Content-Type, If-Modified-Since, Prefer, Range, Referer

 

However, if I select to login anonymously... it wants my credentials:

heriberto_mb_0-1714480535621.png

 

My code:

let gettoken=() =>
    let
    JWT="<my_token>",
    Data= Web.Contents("https://api.github.com/app/installations/<id>/access_tokens", 
                      [
                        Headers=[
                                    #"Accept"="application/vnd.github+json",
                                    #"Authorization"="Bearer" & JWT,
                                    #"X-GitHub-Api-Version"="2022-11-28",
                                    #"Content-Type"="application/x-www-form-urlencoded"                                 
                        ]])
        ,token=Json.Document(Data)[token]
in
    token   
in gettoken

If needed I can open another post.

 

Have you considered using the github connector in Power Query?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.