• 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 to a server

Explorer ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

Hello community,

 

I have been trying to write a JavaScript extension which makes a 'GET' request to a server on pressing of a sub-menu item in Adobe Acrobat professional. After writing the script after following from an online resource(https://gist.github.com/randycasburn/802f278c3cfef0873dd086c34bbb9fee), I tried executing the folder level script but it gave an 'object aggregate' error in console. I tried looking for it online but could not found anything helpful. I think the issue is with the request which is not able to fetch data. Below is the script for the same. Any help regarding this 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

console.println(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});

 

Below is the screenshot of the error:

 

Screenshot (32).png

TOPICS
Acrobat SDK and JavaScript

Views

1.2K

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

correct answers 1 Correct answer

Community Expert , May 29, 2020 May 29, 2020

(and if toString doesn't work try toSource)

Votes

Translate

Translate
LEGEND ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

Please copy and paste the entire console message. There is often more clue around the message than it first appears.

Votes

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
Explorer ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

updated now.

Votes

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
LEGEND ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

Actually, I think the problem is that "e" is not a string, and cannot be made one. 

oException An exception object if the method was not successful. The
exception object has the following properties:
error — the HTTP status code that was returned.
msg — An error message associated with the failure.

Votes

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
Community Expert ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

Change:

"ERROR: " + e

To:

"ERROR: " + e.toString()

Votes

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
Community Expert ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

(and if toString doesn't work try toSource)

Votes

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
Explorer ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

Thanks! It worked. But now it is showing "error:-8","text: There was a problem connecting to the server ", "type: Network Error". Any clue as to why is this error?

Votes

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
LEGEND ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

Ah, I understand. There is no error. This is not a JavaScript failure or error message: it is YOUR message, as created in the line you noted: var error = e == undefined? 'No HTTP errors' : "ERROR: " + e; 

because the value of e, which is an object, if you force it into a string context is "[object Aggregate]".

So I hope from the other replies you now know why this happens, and how you might make the message more useful to you in solving failure of Net.HTTP.request.

Votes

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
LEGEND ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

I tried your code, with your sample site. When I run the menu item I get No HTTP errors returned. Maybe you have a firewall/whitelist issue.

Votes

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
Explorer ,
May 31, 2020 May 31, 2020

Copy link to clipboard

Copied

Oh okay.Thanks a lot! So is this issue URL specific or what and how can I fix the firewall issue?

Votes

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
Community Expert ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

I've used this function quite a bit. You'll find a tester app here:

If it's having a connection problem it's likely that either the URL is bad, or required header parameters are missing. 

 

https://www.pdfscripting.com/public/HTTP-Access-Tester-Description.cfm

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
Explorer ,
May 31, 2020 May 31, 2020

Copy link to clipboard

Copied

I am sorry but I guess this service is paid. Is there any free service?

Votes

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
Community Expert ,
May 31, 2020 May 31, 2020

Copy link to clipboard

Copied

LATEST

Debugging HTTP issues is difficult because there are so many different things involed, the client platform (Acrobat JavaScript), the target server, server security, the target script and it's requirements, cookies, etc.  

 

I created this tool as a test frame so at least I could get a handle on the client. If you want something for free I would suggest writing your own. 

As for figuring out your issue. Acrobat does not provide particularly detailed or acurate error messages. Really all you know is that the server is not responding.

Can you use a browser to test the server side interaction? If this is true, then use the developer tools on the browser to which headers are used. Also, the site your hitting is HTTPS. Are the security issues? perhaps the encryption level?

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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