Search code examples
node.jsmagentoxml-rpc

Connecting to Magento XML-RPC in NodeJS | Unknown XML-RPC tag 'TITLE' error


I am using https://www.npmjs.com/package/magento-api-xmlrpc library in a NodeJS project (running inside Docker) to connect to Magento v1.x via XML-RPC.

I've tested it locally on my windows like this:

let magento = new MagentoAPI({
    host: 'test-domain.com',
    port: 443,
    path: '/api/xmlrpc',
    login: 'api-username',
    pass: 'api-password'
});

magento.login(function(err, sessId) {
    if (err) {
        console.log('Credentials verification failed:\n%j', err);
        return cb(err, { verified: false });
    } else {
        console.log("Login Successful - Session Id: " + sessId);
        return cb(null, { verified: true });
    }
});

and it works:

Login Successful - Session Id: 1d0d9e764d7d955470f92fa93fb53ca8

When I tested this in the docker container (with exact tested config + scripts), I am getting this error:

{"original":{"message":"Unknown XML-RPC tag 'TITLE'","name":"Error"},"name":"Magento Error","message":"An error occurred at login"}

What's strange is that; I only see the above error in windows, if I set the test script's port to 80 (which I know is invalid).

Any ideas what might be going wrong here?


Solution

  • Sorry, this is not a bug!

    It turns out that we had IP white listing on the site I was testing with and after allowing the public IP of the docker container on the magento dev site, it started to work.

    False alarm...