Forum Discussion

cmht's avatar
cmht
Regular Visitor
2 years ago
Solved

API connect - We found extra characters at the end of JSON input

Hello,

I have a problem, I get an error:

DataFormat.Error: We found extra characters at the end of JSON input.

Details:

Value=

Position=0

 

and this is about action =Json.Dcoument(GetJson)

 

Here my code:

let
authKey ="Basic " & AconexAuthorizationPair, //100% works

//Retrieve token from Aconex
GetJson =
Web.Contents(
"https://eu1.aconex.com/api/projects/XXXXXXXXXX/register",
[
Headers=[
#"Accept"="application/xml",
#"X-Application-Key"=AconexIntegrationID,
#"Authorization"=authKey
],
Query=[
#"search_query"="doctype:Plan",
#"return_fields"="trackingid,title,doctype,docno,attribute1,forreview,filename,fileType,fileSize"]
]
),

FromatAsJson = Json.Document(GetJson),

//Extract token from Json response
AccessToken = FromatAsJson[access_token]

in
AccessToken
 
Please let me know what I am doing wrong, below a Power Automate action which works:

 

of course above in Power Automate I just provide normal username and password, with PowerBI it is in a Base64 format username:password - but this works.

 

I think there is no token exchange, I have this code as I found it somewhere in connections with OAuth2 for Spotify, here I just need a plain JSON response, I think problem is caused after Web.Contents -> and this is a place where I don't knwo what to do.

 

Any help would be appreciated.

  • Hi,

    I solved the issue by changing the Query, as it is not JSON -> it gives back valid XML in binary.

    Now everything works.

2 Replies

  • cmht's avatar
    cmht
    Regular Visitor

    Hi,

    I solved the issue by changing the Query, as it is not JSON -> it gives back valid XML in binary.

    Now everything works.

  • Instead of attempting to parse the JSON, have a look at the raw output that comes back.