9 Replies Latest reply on Aug 28, 2012 6:32 AM by Dave Merchant

    How to use Net.HTTP.request in Reader, not in Acrobat?

    ericwangqing

      I found that it seemed impossible to use Net.HTTP.request in Reader.

       

      What I want is to post data to my server when doc, "DidSave", and I've realized it successfully in Acrobat via a method wrapped Net.HTTP.request and running in non-privilleged context via app.trustedFunction.

       

      But when I copied the same js file into Reader's App javascript folder, and ran the script in Reader. It threw a "NotAllowedError" when I tried to save file. However, if the wrapping method had called from the initialization, not in app, it would run smoothly without any error.

       

      I checked the api reference and also searched the forums, but unfortunately nothing can explain this.

       

      Does that means the Net.HTTP.request method can't be used in Reader at app or doc context, even via app.trustedFunction?

      Is there anyone kindly help me out of the mass?

       

      ---- The Code -----

       

      myTrustedHTTPTest = app.trustedFunction( function ()
      {
      app.beginPriv();

       

      // start of trusted method
          var requestString = "Hello World!";
          var srcStm = SOAP.streamFromString(requestString);

       

          console.println("start testing HTTP ...");
          console.println(requestString);
          var myTrustedRetn = Net.HTTP.request({
              cVerb: "POST",
              cURL: "http://127.0.0.1:8888",
              oRequest: srcStm
              });
          console.println("end testing HTTP ...");

       

      // end of trusted method

       

      app.endPriv();
      return myTrustedRetn;
      });

       

      ......

       

      doc.setAction("DidSave", "myTrustedHTTPTest();");

       

      ......