importJSON from api with user and password

Anyone tried to importJSON from an api where username and password is required?
@Vicio_Sciascia @ThinhDinh

The importJSON from this source:

As example - I’m trying to import data from Cloudinary

If you succeed - how do you do it?

Can you try if the method by thadk here works?

1 Like

Hi @Krivo, I don’t know if I understood correctly what you are trying to do man, but to me it’s seems easier than that: according to Cloudinary documentation you have to pass your API Key and API Secret (used for the authentication) as part of the API’s URL.

So what you have to do is: go to your Cloudinary dashboard and copy your API Key, API Secret and Cloud name:

And paste them as part of API URL. Here’s an example in Postman:

Basically your importJSON formula would be something like that:


I think that the piece of script in the link posted by @ThinhDinh is useful when you have to deal with APIs with basic auth authorization method, but I think it’s not our case with Cloudinary :slight_smile:

1 Like

Forgotten to say: glad to read that you’re practicing with APIs!

Kudos and keep going :love_you_gesture:

1 Like

@Vicio_Sciascia @ThinhDinh

It is not possible to use a simple importJSON function as it will not allow login information which can be seen by the exception

Exception: Login information disallowed:

But the link that Thinh supplied does work.

Add this to your importJSON script

function ImportJSONBasicAuthentication(url, query, parseOptions, username, password) {

var fetchOptions = {
“headers” : {
“Authorization” : 'Basic ’ + Utilities.base64Encode(username + ‘:’ + password)
muteHttpExceptions: true

return ImportJSONAdvanced(url, fetchOptions, query, parseOptions, includeXPath_, defaultTransform_);

and supply the username and password from Cloudinary things then work perfectly

username = API Key
password = API Secret

=ImportJSONBasicAuthentication(“<cloudname>/resources/search?max_results=100&expression=folder=<foldername>%20AND%20filename=2*”,“noHeaders”,<API Key>,<API Secret>)


Good to hear, Krivo. I will surely use this at some point in the future. Thank you :smile:

You’re right @Krivo, perhaps it is some some sort of a bug? I don’t know :confused:
Anyway, good to know and thank you for sharing