# Http request with url fails

**URL:** <https://community.haxe.org/t/http-request-with-url-fails/3249>\
**Category:** Haxe\
**Created:** [September 14, 2021, 4:06pm UTC](https://community.haxe.org/t/http-request-with-url-fails/3249 "2021-09-14T16:06:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lelelo1](https://avatars.discourse-cdn.com/v2/letter/l/9f8e36/32.png) [@Lelelo1](https://community.haxe.org/u/Lelelo1)\
**Post date:** [September 14, 2021, 4:06pm UTC](https://community.haxe.org/t/http-request-with-url-fails/3249/1 "2021-09-14T16:06:55Z")

</div>

I have a problem with the url: `https://overpass-api.de/api/interpreter?data=[out:json];(node[name](57.697255528906794,11.901648888613714,57.709701878362885,11.918365178920073);<;);out meta;`  
It works in the browser, but when I:

```haxe
Http.requestUrl("https://overpass-api.de/api/interpreter?data=[out:json];(node[name](57.697255528906794,11.901648888613714,57.709701878362885,11.918365178920073);<;);out meta;");

```

… I get the following log:

> /usr/local/lib/haxe/std/sys/Http.hx:495: characters 4-9 : Uncaught exception Http Error #400  
> /usr/local/lib/haxe/std/sys/Http.hx:65: characters 4-14 : Called from here  
> /usr/local/lib/haxe/std/sys/Http.hx:251: characters 12-25 : Called from here  
> /usr/local/lib/haxe/std/sys/Http.hx:68: characters 3-30 : Called from here  
> /usr/local/lib/haxe/std/sys/Http.hx:497: characters 3-19 : Called from here  
> src/Service.hx:37: characters 12-179 : Called from here  
> src/Main.hx:7: characters 17-38 : Called from here

What is the problem, has it anything to do with the semicolons?

---

<div class="post-metadata">

**Author:** ![tokiop](https://avatars.discourse-cdn.com/v2/letter/t/bc8723/32.png) [@tokiop](https://community.haxe.org/u/tokiop)\
**Post date:** [September 14, 2021, 5:07pm UTC](https://community.haxe.org/t/http-request-with-url-fails/3249/2 "2021-09-14T17:07:17Z")

</div>

It seems some unsafe url chars need to be escaped, this works for me in both curl and Haxe : `https://overpass-api.de/api/interpreter?data=%5Bout%3Ajson%5D;(node%5Bname%5D(57.697255528906794,11.901648888613714,57.709701878362885,11.918365178920073);%3C;);out%20meta;`

---

<div class="post-metadata">

**Author:** ![Lelelo1](https://avatars.discourse-cdn.com/v2/letter/l/9f8e36/32.png) [@Lelelo1](https://community.haxe.org/u/Lelelo1)\
**Post date:** [September 15, 2021, 6:42am UTC](https://community.haxe.org/t/http-request-with-url-fails/3249/3 "2021-09-15T06:42:45Z")

</div>

> [@tokiop](#):
>
> [https://overpass-api.de/api/interpreter?data=[out%3Ajson];(node[name](57.697255528906794,11.901648888613714,57.709701878362885,11.918365178920073);\<;](https://overpass-api.de/api/interpreter?data=%5Bout%3Ajson%5D;(node%5Bname%5D(57.697255528906794,11.901648888613714,57.709701878362885,11.918365178920073);%3C;));out%20meta;

Thanks that worked.  
I found a table that helped me see the changes: [URL Escape Codes](https://www.december.com/html/spec/esccodes.html)

---

<div class="post-metadata">

**Author:** ![tokiop](https://avatars.discourse-cdn.com/v2/letter/t/bc8723/32.png) [@tokiop](https://community.haxe.org/u/tokiop)\
**Post date:** [September 15, 2021, 11:53am UTC](https://community.haxe.org/t/http-request-with-url-fails/3249/4 "2021-09-15T11:53:03Z")

</div>

Nice ! [StringTools.urlEncode()](https://api.haxe.org/StringTools.html#urlEncode) can escape these characters, but passing the full url through it mangles it too much, and overpass seems a bit sensitive too so it is was trial and error.
