Skip to main content
Participating Frequently
April 2, 2019
Question

Error called get request

  • April 2, 2019
  • 2 replies
  • 1777 views

Hi, I'm trying to send a GET request with Net.HTTP.request to http://dummy.restapiexample.com/ , actually I'm calling this endpoint: http://dummy.restapiexample.com/api/v1/employee/7052

No matter what I try I always get this error:

NotAllowedError: Security settings prevent access to this property or method.

It's a js which is being called at document level, improved security is disabled and I've also tried enabling it.

the code is -->

//<Document-Level>

//<ACRO_source>Init</ACRO_source>

//<ACRO_script>

/**** pertenece a: Document-Level:Init ****/

myTrustedFunction = app.trustedFunction(

    function()

    {

        this.getField("textAJAX").display = display.hidden;

        console.println("2 - ");

        Net.HTTP.request({

            cVerb: 'GET',

            cURL: 'http://dummy.restapiexample.com/api/v1/employee/7052',

            oHandler: {

                response: function(msg, uri, err) {

                    if (err != undefined) {

                        app.alert(msg)

                    } else {

                        console.println("1");

                        var stream = msg;

                        console.println(stream);

                    };

                }

            }

        });

    }

);

//</ACRO_script>

This topic has been closed for replies.

2 replies

Bernd Alheit
Community Expert
Community Expert
April 2, 2019

You must use the trusted function in a folder level file.

Thom Parker
Community Expert
Community Expert
April 2, 2019

This is a privileged operation.  If you want to run it from a document script, then the document has to be trusted. You can do this by marking it as trusted in the "Enhanced Security" Preference, or by digitally certifying it with scripting privileges. Otherwise it has to be done from a trusted function in a folder level script.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
EncaminaAuthor
Participating Frequently
April 3, 2019

Thx, in acrobat is working.

But it doesn't work in Adobe Reader.

The steps were:
"You can do this by marking it as trusted in the "Enhanced Security" Preference"

Code:

myTrustedFunction = app.trustedFunction(

    function()

    {

        var drop= this.getField("dropEmp");

        drop.setItems(new Array([]));

        var employee=[["",""]];

        app.alert("Reader");

        Net.HTTP.request({

            cVerb: 'GET',

            cURL: 'http://dummy.restapiexample.com/api/v1/employees',

            oHandler: {

                response: function(msg, uri, err) {

                    if (err != undefined) {

                        app.alert(msg)

                    } else {                                               

                        var stream = msg;

                        console.println(msg);

                        var string = SOAP.stringFromStream( stream );

                        var json= JSON.parse(string);

                        for (var i = 0; i < 5; i++) {                           

                            employee.push(

                                [

                                    json.id.toString(),

                                    json.id.toString()

                                ]);   

                        }

                       drop.setItems(employee);                        

                    };

                }

            }

        }); 

    }

);

myTrustedFunction();

Bernd Alheit
Community Expert
Community Expert
April 3, 2019

You need special forms rights for the use in Acrobat Reader.