Skip to content

Instantly share code, notes, and snippets.

@random82
Last active April 3, 2019 02:57
Show Gist options
  • Save random82/d902eb81a1a1663fac83d035feb485d7 to your computer and use it in GitHub Desktop.
Save random82/d902eb81a1a1663fac83d035feb485d7 to your computer and use it in GitHub Desktop.
Basic HTTP authorisation with PowerQuery
let EncodeBasicCredentials = (UserName, Password) =>
let
result = "Basic " & Binary.ToText(Text.ToBinary(#"UserName" & ":" & #"Password"),0)
in
result
in EncodeBasicCredentials
let
UserName = "USERNAME",
Password = "PASSWORD",
authHeader = EncodeBasicCredentials(UserName, Password),
options = [
Headers = [
#"Authorization"=authKey
]
],
Headers = options[Headers],
Url = "https://api.myprovider.com/api/v1.0/something.json",
Result = Json.Document(Web.Contents(Url, options)),
Result1 = Result{0}
in
Result1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment