Forum Discussion

LeonardSchwenk's avatar
LeonardSchwenk
Frequent Visitor
4 years ago
Solved

REST API CALL in function wont work due to invalid input

My function looks like the following.     = (playerId as text) as table=> let Source = Json.Document( Web.Contents( "https://api.greatAPI.io/v1/", [ ...
  • ImkeF's avatar
    4 years ago

    Hi LeonardSchwenk ,
    the Web.Contents function only accepts 2 parameters. So you have to nest the records into one like so:


    (playerId as text) as table=>
    let
        Source = Json.Document(
    
            Web.Contents(
                "https://api.greatAPI.io/v1/",
                [
                    RelativePath ="players/" & (playerId)
                ,
                    
                        Headers=
                        [
                            Accept="application/json", Authorization="Bearer XXXXXXXXXXXXXXX"
                        ]
                ]))
    in
        #"Source"
  • ImkeF's avatar
    4 years ago

    Hi LeonardSchwenk ,
    no, it's not.
    There is no opening square bracket before "Headers" for example.
    I'd recommend to try it out.