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
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
mmbr1606
9
Super User 2025 Season 1
stampcoin
7
SD-13050734-0
6