# Getting The request body was not well-formed

**URL:** <https://devforum.okta.com/t/getting-the-request-body-was-not-well-formed/3947>\
**Category:** Questions\
**Created:** [January 18, 2019, 3:17am UTC](https://devforum.okta.com/t/getting-the-request-body-was-not-well-formed/3947 "2019-01-18T03:17:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![afalahi](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/afalahi/32/899_2.png) [@afalahi](https://devforum.okta.com/u/afalahi)\
**Post date:** [January 18, 2019, 3:17am UTC](https://devforum.okta.com/t/getting-the-request-body-was-not-well-formed/3947/1 "2019-01-18T03:17:52Z")

</div>

gettin this error when attempting to create a new user via API. Using express and bodyParser to parse form body, serialize it into JSON, and then send it to OKTA. tried various formats, but all the same. What am I missing?

```json
'{"profile":
{
"firstName":"Peter",
"lastName":"Parker",
"email":"pparker@mailinator.com",
"login":"pparker@mailinator.com"
},
"groupIds":[
"00giqta1l0kbfK1QO0h7",
"00gj0t0ieicAW2Iss0h7"
]}'

```

my code:

```javascript
 req.body.user.profile.login = req.body.user.profile.email;
  let data = JSON.stringify(req.body.user)
rp.post({
    uri: `https://dev-451953.oktapreview.com/api/v1/users`,
    json: true,
    headers: {Authorization: `SSWS ${process.env.OKTA_TOKEN}`},
    body: `'${data}'`
  })

```

the error:

```json
StatusCodeError: 400 -
 {"errorCode":"E0000003",
"errorSummary":"The request body was not well-formed.",
"errorLink":"E0000003",
"errorId":"oaeus1TJwgrSI2dKIPypAmZVA",
"errorCauses":[]}

```

---

<div class="post-metadata">

**Author:** ![afalahi](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/afalahi/32/899_2.png) [@afalahi](https://devforum.okta.com/u/afalahi)\
**Post date:** [January 18, 2019, 4:55am UTC](https://devforum.okta.com/t/getting-the-request-body-was-not-well-formed/3947/2 "2019-01-18T04:55:03Z")

</div>

So i’ve noticed that if I remove the groups then it works fine…

---

<div class="post-metadata">

**Author:** ![bdemers](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/bdemers/32/23_2.png) [@bdemers](https://devforum.okta.com/u/bdemers)\
**Post date:** [January 18, 2019, 2:40pm UTC](https://devforum.okta.com/t/getting-the-request-body-was-not-well-formed/3947/3 "2019-01-18T14:40:24Z")

</div>

Are you creating a user or updating one? Setting the `groupIds` field only works when creating a new user. For existing users you can use this: [https://developer.okta.com/docs/api/resources/groups#add-user-to-group](https://developer.okta.com/docs/api/resources/groups#add-user-to-group)

---

<div class="post-metadata">

**Author:** ![afalahi](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/afalahi/32/899_2.png) [@afalahi](https://devforum.okta.com/u/afalahi)\
**Post date:** [January 18, 2019, 2:49pm UTC](https://devforum.okta.com/t/getting-the-request-body-was-not-well-formed/3947/4 "2019-01-18T14:49:42Z")

</div>

I am creating a user from scratch, which is reflected in the URI. I even tried the example provided on Okta’s page using Postman and it failed.

---

<div class="post-metadata">

**Author:** ![afalahi](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/afalahi/32/899_2.png) [@afalahi](https://devforum.okta.com/u/afalahi)\
**Post date:** [January 20, 2019, 2:31am UTC](https://devforum.okta.com/t/getting-the-request-body-was-not-well-formed/3947/5 "2019-01-20T02:31:58Z")

</div>

solved my issues by updating the groups later. not sure what’s going on.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 17, 2024, 7:33pm UTC](https://devforum.okta.com/t/getting-the-request-body-was-not-well-formed/3947/6 "2024-01-17T19:33:28Z")

</div>

Closed on January 17, 2024, 7:33pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
