xmlconnectionodatabasicanonymous

Power Query In Excel Getting Errors


I'm trying to figure out why this post request isn't working in Excel Power Query

let 
    actualUrl = "fakeurl123",
    record = [grant_type="password",username="username",password="password"],
    body = Text.ToBinary(Uri.BuildQueryString(record)),
    uaaBasicKey= "Basic {encoded text}",
    options = [Headers =[#"Content-type"="application/x-www-form-urlencoded", #"Accept"="application/json", #"Authorization" = uaaBasicKey], Content=body],
    Source = Web.Contents(actualUrl, options),
    retVal = Json.Document(Source,65001),
    token = retVal[access_token]
in
    token

When I run the code with the correct password,username, key,etc I get an error saying that I can't use Web.Contents with the content option that I have because it is only supported when connecting anonymously. However, when I do change my connection to anonymous in settings it says I don't have the correct authentication even though I know it's right. If you have any solutions please let me know. Thanks


Solution

  • Needed to change username and password as those were for anonymous connecting.