# Is there a way to automatically encode urls?

**URL:** <https://community.postman.com/t/is-there-a-way-to-automatically-encode-urls/874>\
**Category:** Help Hub\
**Tags:** request, url-encoding\
**Created:** [February 3, 2018, 6:23am UTC](https://community.postman.com/t/is-there-a-way-to-automatically-encode-urls/874 "2018-02-03T06:23:13Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![rolfmadsen](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/rolfmadsen/32/952_2.png) [@rolfmadsen](https://community.postman.com/u/rolfmadsen)\
**Post date:** [September 26, 2018, 7:44am UTC](https://community.postman.com/t/is-there-a-way-to-automatically-encode-urls/874/3 "2018-09-26T07:44:55Z")

</div>

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!

---

_[View the full topic](https://community.postman.com/t/is-there-a-way-to-automatically-encode-urls/874)._
