Copy link to clipboard
Copied
Here is what I want to do:
I want to Do HTTP Get Calls and HTTP Post Calls From my PDF and Im facing the issue where it says
Request error: NotAllowedError: Security settings prevent access to this property or method.
My privilaged function:
~/Library/Application\ Support/Adobe/Acrobat/DC/JavaScripts/trustedNet.js
var trustedNetRequest = app.trustedFunction(function(cURL) {
app.beginPriv();
try {
Net.HTTP.request({
cURL: cURL,
cMethod: "GET",
oHandler: {
response: function(msg) {
console.println("Response: " + msg);
app.alert("API Response: " + msg);
},
error: function(e) {
console.println("Error: " + e);
app.alert("Error: " + e);
}
}
});
} catch (e) {
console.println("Request error: " + e);
app.alert("Request error: " + e);
}
app.endPriv();
});
In PDF:
function testAPI() {
try {
trustedNetRequest("https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd");
} catch (e) {
app.alert("Unable to call privileged function: " + e);
}
}
I tried it with folder-level privileged javascript function, with all Enhanced security off and I still get this error. Need help asap.Thanks!
Copy link to clipboard
Copied
Notice that in the reference entry for the Net.HTTP.request function that the "Product field on the Rights bar" is set to "F". This means the PDF requires form rights in addition to privilege. Form Rights is unfortunately a broad category. There are several form rights. Like form filling, which is given automatically. But form rights for HTTP access is a different thing. It's not free.
Your best way around this restriction is to use a regular form submit to a PHP (or other) sever script, which then makes the HTTP call you want, and then returns the result to a hidden form field. This however is still a privileged operation that will be blocked until the user approves the operation.
Copy link to clipboard
Copied
How can I get the response, because form submission seems to be a one way proccess
Copy link to clipboard
Copied
All HTTP operations are a handshake. Form submission is a specialized case, but it is still a handshake. Quite literally it is either an HTTP Get or Put. Only the submission follows a specific format. It's all outlined in the reference.
I'd be happy to provide you with custom help for a fee. PM me on this forum.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now