Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Rest API Authentication API-Key

Hey guys,    so I'm new into power bi and the power query m language and never worked with that. Basically I'm trying to connect a rest api with my power bi. In order to get the data, I'll have t...
  • lbendlin's avatar
    5 years ago

    If the API requires a POST call then you need to put the data in the body, not the header.  Consult the API documentation, and then use Json.FromValue() to binary encode the payload.

     

    Like so:

    let
        URL = "http://xxx/tstat",
        headers = [#"Content-Type"="application/json"],
        data = Json.FromValue([tmode = 2,t_cool = Setpoint,hold = 0]),
        web = Web.Contents(URL, [ Content = data, Headers = headers, ManualStatusHandling = {404, 400}]),
        result = Json.Document(web),
    ...
  • lbendlin's avatar
    lbendlin
    5 years ago

    you are missing the quotes around the key

     

    data = Json.FromValue([apiKey = "123ABC"]),