Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Call JSON url and get data in AEM through INDS script [Extendscript]

annaduraim74336
Level 2
Level 2

Hi All,

I need to call .json URL link through extend script to do some backend functionality in InDesign server. Is it possible to get JSON data through Javascript?

I tried some code. But this does not return any data.

var host = "http://localhost:4502/bin/querybuilder.json?p.limit=-1&type=dam%3aAsset";

var jsonData = getData(host);

function getData(host) {

    var aemConn = new Socket, body = "", response, firstRead = true;

aemConn.timeout = 60;

    if (!aemConn.open(host, "UTF-8")) {

        return;

    }

    while( response = aemConn.read() ){

        response = response.toString();

        if(!firstRead){

            body = body + response;

            continue;

        }

        var strings = response.split("\n");

        for(var x = 0; x < strings.length; x++){

            if( (x == 0) && (strings[x].indexOf("200") === -1)){

                return body;

            }

            if(x === (strings.length - 1)){

                body = body + strings[x];

            }

        }

        firstRead = false;

    }

    return body;

}

Please give me any helps!

Thanks.

0 Replies