# Trouble creating user with custom user fields with the API

**URL:** https://meta.discourse.org/t/trouble-creating-user-with-custom-user-fields-with-the-api/148434
**Category:** Support
**Created:** [April 18, 2020, 11:47am UTC](https://meta.discourse.org/t/trouble-creating-user-with-custom-user-fields-with-the-api/148434 "2020-04-18T11:47:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![NathanLei](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@NathanLei](https://meta.discourse.org/u/NathanLei)
#### Post date: [April 18, 2020, 11:47am UTC](https://meta.discourse.org/t/trouble-creating-user-with-custom-user-fields-with-the-api/148434/1 "2020-04-18T11:47:58Z")

</div>

When I try to create a user via API with “user\_fields[1]”. which is the customer field.

When I do the testing via postman, it works fine.

but When I tried it via code. it never works. so wired.

here is my payload

```
{

"name": "asdsd",
"email": "sd1sf@asasas.com",
"password": "b366202d-fcc4-46da-9fed-cd57348f2ad2",
"username": "wED18oxlz3",
"active": true,
"approved": false,
"user_fields[1]": "huhsdsd",
"user_fields[2]": "huhsdsdhuhsdsdhuhsdsd"

},

```

same payload works on postman.

I belive it related with the format of user\_fields[1] .

---

<div class="post-metadata">

### Author: ![NathanLei](https://avatars.discourse-cdn.com/v4/letter/n/6bbea6/32.png) [@NathanLei](https://meta.discourse.org/u/NathanLei)
#### Post date: [April 28, 2020, 5:26am UTC](https://meta.discourse.org/t/trouble-creating-user-with-custom-user-fields-with-the-api/148434/2 "2020-04-28T05:26:47Z")

</div>

I have finally solved by myself.

1 make sure using.

> ‘Content-Type’: ‘multipart/form-data’,

as the header

2 make sure your form data is a JSON string . not an object.

I use nodejs, and. I need qs.Stringify my params.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [May 28, 2020, 5:26am UTC](https://meta.discourse.org/t/trouble-creating-user-with-custom-user-fields-with-the-api/148434/3 "2020-05-28T05:26:53Z")

</div>

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