Why is "~" in the payload percent-encoded as "%7E" when the DataWeave output is application/x-www-form-urlencoded?
The DataWeave urlencoded writer (UrlEncodedWriter) encodes each key and value with java.net.URLEncoder. URLEncoder implements the HTML form-encoding rules: it leaves only letters, digits and "* - . _" unencoded, writes a space as "+", and percent-encodes everything else, including "~". For example:
a~b c -> a%7Eb+c
This matches the application/x-www-form-urlencoded format defined by the HTML/WHATWG URL standard, which also encodes "~". RFC 3986 section 2.3 lists "~" as unreserved, but RFC 3986 defines generic URI syntax, not form bodies. The difference between URLEncoder and RFC 3986 is tracked by the OpenJDK issue JDK-8204530 (open); DataWeave follows the JDK behaviour.
The encoding does not change the data. Any compliant form decoder converts "%7E" back to "~", and RFC 3986 section 2.3 also states that URIs differing only in the percent-encoding of an unreserved character are equivalent.
If a receiving system rejects "%7E", that system is not decoding form data correctly. Raise it with the owner of that system first. As a last resort, the encoded string can be post-processed, for example:
write(payload, "application/x-www-form-urlencoded") replace "%7E" with "~"
This is a custom workaround, not a product feature. Test it against the receiving system.
001114352

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.