# Error with XMLHttpRequest

**URL:** <https://forums.fusetools.com/t/error-with-xmlhttprequest/4916>\
**Category:** How-to Discussions\
**Created:** [January 8, 2016, 6:18pm UTC](https://forums.fusetools.com/t/error-with-xmlhttprequest/4916 "2016-01-08T18:18:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cristian\_Karmy1](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/cristian_karmy1/32/480_2.png) [@Cristian\_Karmy1](https://forums.fusetools.com/u/Cristian_Karmy1)\
**Post date:** [January 8, 2016, 6:18pm UTC](https://forums.fusetools.com/t/error-with-xmlhttprequest/4916/1 "2016-01-08T18:18:01Z")

</div>

Hi, I’m trying to send some parameters via a POST method but I get this error:

```auto
ERROR: First argument should be of type System.String
    System.ArgumentException occured.

```

My code is:

```auto
var http = new XMLHttpRequest();
var url = "xxxxxxx";
var params = "param1=xxx&param2=xxx";
http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");

http.onreadystatechange = function() {//Call a function when the state changes.
    if(http.readyState == 4 && http.status == 200) {
        debug_log(http.responseText);
    }
}
http.send(params);

```

What I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![Bjorn-Olav\_Strand](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bjorn-olav_strand/32/583_2.png) [@Bjorn-Olav\_Strand](https://forums.fusetools.com/u/Bjorn-Olav_Strand)\
**Post date:** [January 8, 2016, 6:29pm UTC](https://forums.fusetools.com/t/error-with-xmlhttprequest/4916/2 "2016-01-08T18:29:23Z")

</div>

`params.length` is an integer. You need to cast as string from JS:

```auto
http.setRequestHeader("Content-length", ""+params.length);

```
