Forum Discussion
EduardoRocha96
2 years agoNew Member
(415): Unsupported Media Type - Json
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_cred...
- Anonymous2 years ago
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
Anonymous
2 years agoNot applicable
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.
EduardoRocha96
2 years agoNew Member
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"