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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Markzolotoy
Impactful Individual
Impactful Individual

Error accessing API

I have to following code:

EncodedCredentials = Binary.ToText(Text.ToBinary("client_id" & ":" & client_id, "username" & ":" & username, 
    "client_secret" & ":" & client_secret, "grant_type" & ":" & grant_type, 
    BinaryEncoding.Base64)),
  
    data  = Json.Document(Web.Contents(api_url,
    [ 
      Headers = [#"Content-Type"="application/x-www-form-urlencoded"],
      Content=Text.ToBinary(EncodedCredentials)
    ]
    )
    )

where I need to send 5 parameters. I am getitng tthis error:

5 arguments were passed to a function which expects between 1 and 3.

 

Any what tha is?

 

Thanks

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Markzolotoy 

Your call to Text.ToBinary has too many arguments.

You should be supplying a string and an encoding type but you are supplying several strings because you are splitting them up with commas.

 

Text.ToBinary("client_id" & ":" & client_id, "username" & ":" & username, "client_secret" & ":" & client_secret, "grant_type" & ":" & grant_type, BinaryEncoding.Base64)

 

 

Remove the commas and make just a single string as the first argument.  Something like this

Text.ToBinary("client_id" & ":" & client_id & ",username" & ":" & username & ",client_secret" & ":" & client_secret & ",grant_type" & ":" & grant_type, BinaryEncoding.Base64)

 

The exact format will depend on what your API requires.

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

2 REPLIES 2
Markzolotoy
Impactful Individual
Impactful Individual

While I am not getting the rrror anymore the backend still returns 400. That's why I am asking about Fiddler in the other thread.

PhilipTreacy
Super User
Super User

Hi @Markzolotoy 

Your call to Text.ToBinary has too many arguments.

You should be supplying a string and an encoding type but you are supplying several strings because you are splitting them up with commas.

 

Text.ToBinary("client_id" & ":" & client_id, "username" & ":" & username, "client_secret" & ":" & client_secret, "grant_type" & ":" & grant_type, BinaryEncoding.Base64)

 

 

Remove the commas and make just a single string as the first argument.  Something like this

Text.ToBinary("client_id" & ":" & client_id & ",username" & ":" & username & ",client_secret" & ":" & client_secret & ",grant_type" & ":" & grant_type, BinaryEncoding.Base64)

 

The exact format will depend on what your API requires.

regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.