Remote login request with Power query /.Power BI

Hi guys,

I'm trying to download data from my Knack database straight into Excel.

I've managed to do it following the post here and here. But that exposes my API key in the Advanced Editor which doesnt work for me.

I've been trying to login my user remotely, as described in the developer docs here, but I'm not very good with these codes and was hoping I get more help with it.

The developer docs says I need to make a POST request with a json payload (I'm still trying to understand that), and what I understand is that the Web.Contents function in Power Query lets me make POST requests with the Contents option, as explained here and here.

I've created a sample app with fake data and test logins (the Knack app is here)

  • the email is test@123.com,
  • the password is "2345", and
  • my app id = "5bb71837392f636d991bb30d"

Developer docs example is:

curl -H "Content-Type: application/json" \

--data '{"email":"email address","password":"password"}' \ "https://api.knack.com/v1/applications/YOUR-APP-ID/session"

  • I can tell that -h should correspond to Headers option in Web.Content
  • I'm not sure what --data is meant to be for Web.Content in Power Query though, ?

I've tried this in Power Query

let
url = "https://api.knack.com/v1/applications/5bb71837392f636d991bb30d/session",
body = "{""email"":""test@123.com"",
""password"":""2345""
}",

Source = Json.Document(Web.Contents(url,

[
Headers =[#"Content-Type"="application/json"],
Content = Text.ToBinary(body) , Timeout=#duration(0,2,0,0)
]
))

in
#"Source"

[Sorry for the interruption to the post] But it wasn't working before I was typing this post.. but it's giving me something now.. Just to share.. this is what I did in Power Query to make it work..

I had to make sure the permissionns in Power Query was set to Anonymous (this part has been giving me issues before)

. But the good news is that I can see the token in my Power Query now..

So.. the next question is....

What do I do with it? (I think I'm getting somewhere.. but if experts out there can just let me know.. it'll be kinda cool.

Thanks for reading anyway.