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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hey guys, Can you help me? I'm trying to generate the accesstoken for integration via API, but I keep getting the same error message.
() =>
let
body = Json.FromValue([
grantType = "client_credentials",
clientId = "clientId",
clientSecret = "clientSecret"
]),
response = Json.Document(
Web.Contents(
url,
[
Headers = [
#"Content-Type" = "application/json"
],
Content = body
]
)
)
in
response[accessToken]
(415): Unsupported Media Type
Details:
DataSourceKind=Web
DataSourcePath=https://merchant-api.ifood.com.br/authentication/v1.0/oauth/token
Url=https://merchant-api.ifood.com.br/authentication/v1.0/oauth/token
Solved! Go to Solution.
@EduardoRocha96 - Json.FromValue is incorrect. You need to define a text string and convert it to a binary file type.
let
url = "https://merchant-api.ifood.com.br/authentication/v1.0/oauth/token",
#"Client Id" = "c9daf25e-6b3d-4e7b-9eed-36792df10be9",
#"Client Secret" = "l4jkpmdp4axfyn60olr8685s85f8yvq3hugf5h1jztq65tjx8mbg209ljcj4bjxd5vg13s1k21gm869oyaa5y509az47ll8buy3",
body = "grantType=client_credentials&clientId=" & #"Client Id" & "&clientSecret=" & #"Client Secret",
#"body to binary" = Text.ToBinary( body ),
response = Web.Contents(
url,
[
Headers = [ #"Content-Type" = "application/x-www-form-urlencoded" ],
Content = #"body to binary"
]
),
open = Json.Document( response ),
token = open[accessToken]
in
token
@EduardoRocha96 - Json.FromValue is incorrect. You need to define a text string and convert it to a binary file type.
let
url = "https://merchant-api.ifood.com.br/authentication/v1.0/oauth/token",
#"Client Id" = "c9daf25e-6b3d-4e7b-9eed-36792df10be9",
#"Client Secret" = "l4jkpmdp4axfyn60olr8685s85f8yvq3hugf5h1jztq65tjx8mbg209ljcj4bjxd5vg13s1k21gm869oyaa5y509az47ll8buy3",
body = "grantType=client_credentials&clientId=" & #"Client Id" & "&clientSecret=" & #"Client Secret",
#"body to binary" = Text.ToBinary( body ),
response = Web.Contents(
url,
[
Headers = [ #"Content-Type" = "application/x-www-form-urlencoded" ],
Content = #"body to binary"
]
),
open = Json.Document( response ),
token = open[accessToken]
in
token
Thanks! It Worked!
If think you need to change the Content Type from "application/json" to "application/x-www-form-urlencoded". Please refer to the following documentation for more information. iFood Developer | Referências . Sorry I can help anymore because it is difficult to test without access.
I tried changing the content-type, but now another error is appearing:
(400) - Bad request
I have trial access if you need it 🙂
clientId = "c9daf25e-6b3d-4e7b-9eed-36792df10be9",
clientSecret = "l4jkpmdp4axfyn60olr8685s85f8yvq3hugf5h1jztq65tjx8mbg209ljcj4bjxd5vg13s1k21gm869oyaa5y509az47ll8buy3"
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |