0

I have tried the following code, but whenever I try to run it, I get redirected to 404 Not Found error page:

var host = "host.name",
        port = port_number,
        username = user_name,
        password = pass_word;

try{
    var sftp : SFTPClient = new dw.svc.SFTPClient();
    sftp.connect(host, port, username, password);
    var data : String = sftp.get("Impex/export/files/filename.xml");
    sftp.disconnect();
}catch(e){
    return "Exception: "+ e;
}

I couldnt find any issue with the code, even if I try to initialize a variable for SFTP by using new SFTPClient() (constructor), I still get redirected to 404 not found error page.

How can I solve this error?

Thanks in advance.

  • I am getting this error after executing your code: Exception: TypeError: [JavaPackage dw.svc.SFTPClient] is not a function, it is object. – Code_Ninja May 16 at 5:45
2

Typically my first response would be: Did you white list the SFTP server via SFCC support?

But, upon further inspection it appears you are trying to use SFTP to connect to the same instance the code is executing on. First, you cannot connect to an instance's own IMPEX directory from that instance. It is blocked at the network level. Second, SFCC servers do not support incoming SFTP connections. Only WebDAV. (Which also does not work directly to the instance you're executing code on.)

0

When I tried to execute your code, it gave me the following error:

Exception: TypeError: [JavaPackage dw.svc.SFTPClient] is not a function, it is object.

Then I thought that there might be an issue with the Class implementation of SFTPClient in your code. To check this I searched Class SFTPClient in the commerce cloud documentation. Here is what is wrong with your code:

I have tried the following code, but whenever I try to run it, I get redirected to 404 Not Found error page:

var host = "host.name",
        port = port_number,
        username = user_name,
        password = pass_word;

try{
    var sftp : dw.net.SFTPClient = new dw.net.SFTPClient();
    sftp.connect(host, port, username, password);
    var data : String = sftp.get("Impex/export/files/filename.xml");
    sftp.disconnect();
}catch(e){
    return "Exception: "+ e;
}

Class SFTPClient is not in the package dw.svc but it is in the package dw.net.

I hope my answer was helpful.

Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.