Manual:Urlencoding

Urlencoding is required in a number of situations. For example, API tokens need to be urlencoded or they will be rejected as invalid.

Wikitext
You can URL encode a string from the wikitext using this magic word:

Result:

Settings headers
Typical code for setting headers, e.g. for API:Edit, would be: