LoadJSON with basic auth - Forum

Forum Navigation
You need to log in to create posts and topics.

LoadJSON with basic auth

I need to get a JSON from url with BASIC AUTH, and i don't see any example in the forum.

I create a javascript subroutine with:

var settings = {
"url": "http://the url'",
"method": "GET",
"timeout": 0,
"headers": {
"Authorization": ["Basic theusernameinbase64=", "Basic thepasswordinbase64"]
},
};

$.ajax(settings).done(function (response) {
console.log (response);
});

And a button to call that subroutine, but how i display the results in a html container?

or can i use LoadJSON action with the username and password in the url, like http://username:password@thesite?

LoadJSON "http://usrname:password@theurl" [myvar]
SetVar [json] [myvar]

AlertBox "Prueba" "[myvar]" ""

 

I tested the second option and iget a null response

I finally use the first option creating a variable in the html container and asign in the subroutine:

var settings = {
  "url": "theurl",
  "method": "GET",
  "timeout": 0,
  "headers": {
    "Authorization": ["Basic usernameinbase64", "Basic passwordinbase64"]
  },
};

$.ajax(settings).done(function (response) {
 $App.json = (response);
});

I have made a plugin (the first one) for this. The only thing you need is to put in a container html [json] and fill the parameters in the plugin.

 

Uploaded files:
  • You need to login to have access to uploads.
luisgutierrezb has reacted to this post.
luisgutierrezb

@emmanuel-fernandez just use a variable to save to information and then access each data separately so you can display each one in a Container. There are some sample apps included with VisualNEO Web to show you how to proceed. I think the included "Simplest Database Sample App", will show you a very similar situation, although data is loaded from a SQLite database.
Also please take a look here:
https://webhelp.visualneo.com/VariableObjects.html
https://webhelp.visualneo.com/JSON1.html

Regards.

Hi, is possible to post source code of plugin, i need to work with supabase, and your plugin with modifications really help me,

regards

@luisgutierrezb what plugin source code do you exactly need?