Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Query
Answered

API Query Error - Unexpected error in JSON input

(0) ShareShare
ReportReport
Posted on by 9

Hi all,

 

I'm trying to generate an authentication token from an API. The first step in using the API is to generate an API token by sending two parameters in the body of a POST request to the API. I've tried using the following code, but I'm getting an error message -DataFormat.Error: We found an unexpected character in the JSON input. Details: Value=e Position=0

 

Following is the code. Any ideas what's wrong here?

let
url = "https://xxx.xxx.com/api/auth",
headers = [#"Content-Type"="application/json"],
body = "{ ""Param1"": ""XXX-XXX-XXX"", ""Param2"": ""YYY-YYY-YYY""}",
Source = Json.Document(Web.Contents(url,[ Content = Text.ToBinary(body), Headers = headers ]))
in
Source

  • Verified answer
    chrisgill Profile Picture
    9 on at
    Re: API Query Error - Unexpected error in JSON input

    I received some help outside of this forum and was able to resolve the issue. The code that worked correctly follows:

     

    let
    url = "https://xxx.xxx.com/api/auth",
    headers = [#"Content-Type"="application/json"],
    body = "{ ""Param1"": ""XXX-XXX-XXX"", ""Param2"": ""YYY-YYY-YYY""}",
    Source = Text.FromBinary(Web.Contents(url,[ Content = Text.ToBinary(body), Headers = headers ]))
    in
    Source

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Query

#1
mmbr1606 Profile Picture

mmbr1606 9 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 7

#3
SD-13050734-0 Profile Picture

SD-13050734-0 6

Overall leaderboard

Featured topics