Is there a way to automatically encode urls?

I am working with some endpoints that take Chinese characters as part of the url parameter. Is there a way to automatically encode urls?

/api/v1/word/你好

Normally I would just have the client encodeURI before sending the request. I’m finding it rather frustrating to have to manually convert all of my urls before using them with postman. It also turns things into something like %E4%BD%A0%E5%A5%BD which means I have to decode it again if I happen to forget what it was beforehand.

Is there a way where the Chinese part of the URL can be put inside a variable? If so, then you can use the pre-request script to read the variable and encode it. Albeit it becomes a bit unreadable compared to having the complete URL.

Also curious, these should get auto encoded, isn’t it @SamvelRaja?

I had the same problem encoding search queries from a data file doing requests in the request runner.

*** Data file ***
q”,
“你好”,

*** Pre request ***
let encoded = encodeURIComponent(data.q);
pm.environment.set(‘query’, encoded);

*** reqeuest URL ***
/api/v1/word/{{query}}

Hope this helps!