# Creating a request with raw json body

**URL:** <https://community.postman.com/t/creating-a-request-with-raw-json-body/25387>\
**Category:** Help Hub\
**Tags:** collections, request\
**Created:** [July 1, 2021, 8:05am UTC](https://community.postman.com/t/creating-a-request-with-raw-json-body/25387 "2021-07-01T08:05:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Victor\_Motogna](https://avatars.discourse-cdn.com/v4/letter/v/7ba0ec/32.png) [@Victor\_Motogna](https://community.postman.com/u/Victor_Motogna)\
**Post date:** [July 1, 2021, 8:05am UTC](https://community.postman.com/t/creating-a-request-with-raw-json-body/25387/1 "2021-07-01T08:05:43Z")

</div>

I am trying to create a request inside a new/update collection API call, having the equivalent of the `raw - json` body inside the client.

Right now, it seems like I need to send something like (I am using ruby, but it shouldn’t make a big different):

```ruby
body: {
  mode: 'raw',
  json: {
    field1: 'value',
    field2: 'value2'
  }
}

```

I want to avoid using `'formdata'`, because I already have the hash and parsing it into formdata format would add extra complexity (especially because I have to handle multiple nests).

When using this, I get a 200, but the generated request has an empty body.

I’ve also tried using mode: raw, text: {}, but same result. Also, I’ve tried

```ruby
body: {
  json: { field: 'value' }             
}

```

and

```ruby
body: { field: 'value' }

```

and it didn’t work.

Is there any way to make this work? Also, didn’t find any examples of how to send the body in the docs.

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [July 1, 2021, 10:22am UTC](https://community.postman.com/t/creating-a-request-with-raw-json-body/25387/2 "2021-07-01T10:22:38Z")

</div>

@Victor_Motogna Welcome to the Community 🥳

You can try something like

```auto
var body = {
    "field1" : "value",
    "field2" : "value2"
  };

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

```

Please refer [this link](https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#sending-requests-from-scripts) for examples 😇

---

<div class="post-metadata">

**Author:** ![Victor\_Motogna](https://avatars.discourse-cdn.com/v4/letter/v/7ba0ec/32.png) [@Victor\_Motogna](https://community.postman.com/u/Victor_Motogna)\
**Post date:** [July 1, 2021, 10:26am UTC](https://community.postman.com/t/creating-a-request-with-raw-json-body/25387/3 "2021-07-01T10:26:24Z")

</div>

That worked great, thanks!

---

<div class="post-metadata">

**Author:** ![mhers](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mhers](https://community.postman.com/u/mhers)\
**Post date:** [August 19, 2022, 8:17am UTC](https://community.postman.com/t/creating-a-request-with-raw-json-body/25387/4 "2022-08-19T08:17:07Z")

</div>

Hi All,

How can I send json object in raw mode without stringify-ing it?  
I have type error from backend which is not a custom error ,but an error from library when sending payload in pre-script using:  
body: {  
mode: ‘raw’,  
raw: JSON.stringify({  
“key”: “value”  
});  
}  
{“detail”:[{“loc”:[“body”],“msg”:“value is not a valid dict”,“type”:“type\_error.dict”}]}

---

<div class="post-metadata">

**Author:** ![mhers](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@mhers](https://community.postman.com/u/mhers)\
**Post date:** [August 19, 2022, 9:33am UTC](https://community.postman.com/t/creating-a-request-with-raw-json-body/25387/5 "2022-08-19T09:33:32Z")

</div>

OK I found the solution:  
We need to add a header with  
content-type: application/json  
))
