Importdata on Google Sheets giving #N/A

When I use IMPORTDATA command on google sheets and provide a publicly shared Metabase question csv link as a parameter, the result is #N/A. I have passed the login, password for authentication in the URL as well.

Please help.

1 Like

No worries, I found the answer. We have a basic authentication set up for Metabase, so I just had to write a Google Apps script to go around it.

2 Likes

Hi Sudeep, can you share more details of how you solved it please? I think I might be facing the same issue. Iā€™m getting ā€œCould not fetch urlā€ when using importdata on metabase public csv link

1 Like

@sudeep Iā€™d love to set this up if youā€™re able to share the auth script you used. Thx!

A google for google+apps+script+basic+authorization spits out:

And then on top if google apps script is new to you (as it is to me) ā€¦ the links in https://stackoverflow.com/tags/google-apps-script/info

Does that work for you?

1 Like

Thanks for your solutions but I already figured it out myself.

All I did was pass the basic auth credentials in the get call:

var resp = UrlFetchApp.fetch(csvUrl, {
headers: {
// use basic auth
ā€˜Authorizationā€™: 'Basic ā€™ + Utilities.base64Encode(
user + ā€˜:ā€™ + pw, Utilities.Charset.UTF_8)
}
});