0

I was going to use PaperCut API though as far as I can judge XML-RPC doesn't support Node.JS or I couldn't find an appropriate client for the purpose. Here's the link with PaperCut API: https://www.papercut.com/support/resources/manuals/ng-mf/common/topics/tools-web-services.html

I was wondering who had been able to get it working in JavaScript. I'm using Node.js in QNAP (in Container Station). If it can be run in Python should I install Python container? Could I use a snippet of code in Python requesting it from Node.js?

halfer
  • 19,824
  • 17
  • 99
  • 186
hazartilirot
  • 195
  • 1
  • 2
  • 11
  • Don't put your tags in the title of your question. Compose a proper title. Imagine you're asking a colleague this question. Would you ask them "PAPERCUT API | XML-RPC | NODE.JS?" – Robert Harvey Sep 20 '20 at 20:02
  • I have tried to summarise what I think is the question in the title. – halfer Sep 20 '20 at 20:03
  • In relation to the question, I assume that the question of whether XML-RPC "supports" Node is a non-sequituur - XML-RPC is XML and therefore can be used in any languages that can read/write XML. – halfer Sep 20 '20 at 20:04
  • The link you've supplied says that Python is supported, but if you would rather use JavaScript/Node, I would be sure that an XML-RPC library is available for that language. [There are several here](https://duckduckgo.com/?q=node.js+xml-rpc&ia=web), and [this is the first one](https://www.npmjs.com/package/xmlrpc). – halfer Sep 20 '20 at 20:06
  • Also appear to be some npm papercut packages – charlietfl Sep 20 '20 at 20:25
  • Well, I have found XML-RPC library in npm, actually it was the first place I went to. The thing is I don't know how to use it in relation to the API. I have no experience and didn't find a documentation on how to send API requests. I read one of support team reply saying that they don't support Node.JS https://www.papercut.com/support/resources/manuals/ng-mf/common/topics/tools-web-services.html#comment-2140826408 Thank you for correcting me. – hazartilirot Sep 20 '20 at 20:27
  • I am the API guy at PaperCut and there is no reason why Node should not work. I'm currently under the pump otherwise I'd try and get an example written ASAP. However bit busy so won't get to it for a few days -- sorry. In the meantime you mind find some useful information in this blog post https://blog.papercut.com/write-xml-rpc-clients/. – Alec the Geek Oct 13 '20 at 06:27
  • Thank you, Alec. I'd emailed you before posting my question here, but I never received a reply back. I read your articles. My problem has been solved. Thank goodness I found ServerCommandProxy.cs file somewhere on the Internet - things went easier. I took API requests from it. on PaperCut web site nothing is said about values support/resources/manuals/ng-mf/common/topics/tools-web-services.html like api.getUserAccountBalance expects 3 values: token, user, accountName if you can provide this information it would be really helpful not just for me but for others as well. – hazartilirot Oct 14 '20 at 08:58
  • Well, I've just found the documentation I needed, I have no idea why it's been placed into that directory. I would never look for the API there. C:\Program Files\PaperCut MF\server\examples\webservices\java\docs\api Incredible things happen sometimes... – hazartilirot Oct 14 '20 at 09:35

1 Answers1

0

I work for PaperCut Software

Sorry it took me so long to reply to this, but I eventually found a free afternoon to knock up some code.

var xmlrpc = require('xmlrpc')

const authToken = 'token'

const hostAddress = "172.24.96.1"
 
// Waits briefly to give the XML-RPC server time to start up and start
// listening
setTimeout(function () {
  // Creates an XML-RPC client. Passes the host information on where to
  // make the XML-RPC calls.
  var client = xmlrpc.createClient({ host: hostAddress, port: 9191, path: '/rpc/api/xmlrpc'})
 
  // Sends a method call to the PaperCut MF/NG server

  client.methodCall(`api.${process.argv[2]}`, [authToken].concat(process.argv.slice(3)), function (error, value) {
    // Results of the method response
    if (undefined === error || null === error) {
        console.log(`Method response for \'${process.argv[2]}\': ${value}`)
    }
    else
    {
        console.log(`Error response for \'${process.argv[2]}\': ${error}`)
    }
  })
 
}, 1000)

To run this from the command line try something like

node main.js getUserProperty alec balance
Alec the Geek
  • 1,970
  • 14
  • 14