Loading

How to URL Encode special characters in transport endpoint URLs

Publiceringsdatum: Aug 5, 2025
Uppgift

GOAL

Mule server requires encoding of special characters when they are used in transports that communicate using a URL string. Examples are SFTP & FTP, but this can apply to other transports also. This applies to both inbound and outbound connectors.

The same concept applies to ANY transport that requires the construction of a standard URL, including HTTP (legacy connector), JDBC, SMTP, IMAP, and others.
Failure to properly URL encode special characters will result in connection errors, typically "access denied", "host not found" or "connection refused" depending if Mule is confused by your credentials or target hostname.
Steg
There are many many tools that allow the creation of URL encoding, especially online web pages. One way to do it programmatically is to use the Java method URLEncoder.encode(). For example, you can use this method from the command line using the Groovy interpreter:
$ groovy -e "println URLEncoder.encode('this%is@test')"
this%25is%40test

Example 1

FTP - special character in password "@"
Host: ftp.mulesoft.com
User: support1978
Pass: ftp@mulesoft

Mule Configuration

<ftp:inbound-endpointconnector-ref="FTP"responseTimeout="10000"doc:name="FTP"host="ftp.mulesoft.com"password="ftp%40mulesoft"path="tempfiles"port="21"user="support1978"></ftp:inbound-endpoint>
or
<ftp:inbound-endpointconnector-ref="FTP"responseTimeout="10000"doc:name="FTP"address="ftp://support1978:ftp%40mulesoft@ftp.mulesoft.com:21/tempfiles"></ftp:inbound-endpoint>

Example 2

SFTP - special character in username "#"
 
Host: sftp.mulesoft.com
User: joe#blogs
Pass: cvbk93sgds

Mule Configuration

<sftp:inbound-endpointconnector-ref="SFTP"host="sftp.mulesoft.com"port="22"path="tempfiles"user="joe%23blogs"password="cvbk93sgds"responseTimeout="10000"doc:name="SFTP"/>

or

<sftp:inbound-endpointconnector-ref="SFTP"responseTimeout="10000"doc:name="SFTP"address="sftp://joe%23blogs:cvbk30sgds@sftp.mulesoft.com:22/tempfiles"></sftp:inbound-endpoint>

References

Knowledge-artikelnummer

001115133

 
Laddar
Salesforce Help | Article