Skip to main content
Inspiring
May 29, 2020
Question

[ object aggregate ] error on making a 'GET' request

  • May 29, 2020
  • 0 replies
  • 319 views

Hello Community,

I have been trying to add a javascript extension to make a 'GET' request to a server upon pressing of a menu item created. On executing the folder level script, I got an 'object aggregate' error. I think it is not able to fetch data using the request. I tried searching for that error online but could not get anything. I am developing this in Adobe Acrobat Professional. Below is the script for the same. Any help would be greatly appreciated.

Thanks.

 

// Make HTTP GET request
ajax = app.trustedFunction(function(fURL) {
app.beginPriv();
Net.HTTP.request({ cVerb:"GET", cURL:fURL, oHandler: ajaxCallback});
app.endPriv();
});


// process the response
ajaxCallback = {
response:function(msg,uri,e){
var stream = msg;
var string = "";
var error = e == undefined? 'No HTTP errors' : "ERROR: " + e;      // Here it is giving [ object aggregate ] error.
string = SOAP.stringFromStream( stream );
oResult = JSON.parse(string);

console.println(error);
console.println( "id: " + oResult.id);
console.println( "userId: " + oResult.userId);
console.println( "title: " + oResult.title);
console.println( "body: " + oResult.body);
}
};


// Add menu item to kick it all off
app.addMenuItem({
cName: "Get Mock Data", cParent: "File",
cExec: 'ajax("https://jsonplaceholder.typicode.com/posts/1");',
nPos: 0});

 

This topic has been closed for replies.