# Body Drops When Sending POST Request in Script

**URL:** <https://community.postman.com/t/body-drops-when-sending-post-request-in-script/684>\
**Category:** Help Hub\
**Tags:** pre-request, post\
**Created:** [January 14, 2018, 2:32pm UTC](https://community.postman.com/t/body-drops-when-sending-post-request-in-script/684 "2018-01-14T14:32:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jnfSmile](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jnfsmile/32/249_2.png) [@jnfSmile](https://community.postman.com/u/jnfSmile)\
**Post date:** [January 14, 2018, 2:32pm UTC](https://community.postman.com/t/body-drops-when-sending-post-request-in-script/684/1 "2018-01-14T14:32:14Z")

</div>

I’m trying to send a request in a pre-request script:

```
var reqParams = {
    url: 'localhost:8090/my-app',
    method: "POST",
    header: {
       "Content-Type": "application/json",
       "Accept":"application/json",
       ...
    },
    body: {
    	"key": { ... }
    }
};
pm.sendRequest(reqParams, function (err, response) { ... });

```

In the console I see the request is sent but has no body, `Content-Length` header is `""`

Is this a known issue in any way? Any suggestions?

---

<div class="post-metadata">

**Author:** ![abhijitkane1](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/abhijitkane1/32/4_2.png) [@abhijitkane1](https://community.postman.com/u/abhijitkane1)\
**Post date:** [January 15, 2018, 9:01am UTC](https://community.postman.com/t/body-drops-when-sending-post-request-in-script/684/2 "2018-01-15T09:01:37Z")

</div>

Hi @jnfSmile

You’ll need to use the correct syntax for the body property:

```
 body: {
      mode: 'raw',
      raw: JSON.stringify({object})
 }
```

---

<div class="post-metadata">

**Author:** ![jnfSmile](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jnfsmile/32/249_2.png) [@jnfSmile](https://community.postman.com/u/jnfSmile)\
**Post date:** [January 15, 2018, 9:46am UTC](https://community.postman.com/t/body-drops-when-sending-post-request-in-script/684/3 "2018-01-15T09:46:13Z")

</div>

Thanks @abhijitkane1

is it possible to give `mode: json`?

---

<div class="post-metadata">

**Author:** ![bartlbee](https://avatars.discourse-cdn.com/v4/letter/b/e47774/32.png) [@bartlbee](https://community.postman.com/u/bartlbee)\
**Post date:** [January 16, 2018, 12:49pm UTC](https://community.postman.com/t/body-drops-when-sending-post-request-in-script/684/4 "2018-01-16T12:49:07Z")

</div>

@jnfSmile, not according to the Postman [SDK docs](http://www.postmanlabs.com/postman-collection/RequestBody.html).

My general approach to performing scripted requests is to:

1. create a working request in GUI,
2. `console.log(pm.request)`,
3. replicate logged data structure in script

Currently I have a problem with preparing a `urlencoded` request body for a ‘GUI’ request in its pre-request script. After updating it, it can be read and logged by console.log but the new body is not sent over the network when clicking the interactive Send button. A bit confusing.

---

<div class="post-metadata">

**Author:** ![jnfSmile](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/jnfsmile/32/249_2.png) [@jnfSmile](https://community.postman.com/u/jnfSmile)\
**Post date:** [January 16, 2018, 7:23pm UTC](https://community.postman.com/t/body-drops-when-sending-post-request-in-script/684/5 "2018-01-16T19:23:02Z")

</div>

Guess I didn’t get that when I looked in the docs. Thanks!
