# Querying Web.Contents with basic authentication



## mariaanto (Oct 24, 2016)

Hi,
I need to fetch data from lotus notes view to excel using power query. I could able to manually provide username/password in data source settings and query the data. Its working well. I need to do it in Formula language.

Can any one help me to add basic authentication headers in Web.Contents function?

Thanks


----------



## mariaanto (Oct 27, 2016)

mariaanto said:


> Hi,
> I need to fetch data from lotus notes view to excel using power query. I could able to manually provide username/password in data source settings and query the data. Its working well. I need to do it in Formula language.
> 
> Can any one help me to add basic authentication headers in Web.Contents function?
> ...




Finally found the answer: we have to use the header [Headers =[#"Authorization"="*Basic *usernameasword"]]
And the username and password string should be encoded using base64 encoding. For encoding use the link https://www.base64encode.org/

let
   actualUrl = "URL",
   options = [Headers =[#"Authorization"="Basic dXNlcm5hbWU6cGFzc3dvcmQ="]],
   result = Json.Document(Web.Contents(actualUrl, options))
in
    result



In the above query, the string

dXNlcm5hbWU6cGFzc3dvcmQ= is the base64 encoded string of sample credential *usernameasword

Thanks
Maria Lawrence Antony*


----------

