• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Explorer ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

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});

 

TOPICS
Acrobat SDK and JavaScript

Views

222

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation