# Error 400 for post user registration custom action

**URL:** <https://community.auth0.com/t/error-400-for-post-user-registration-custom-action/78618>\
**Category:** Get Help\
**Created:** [February 20, 2022, 3:31pm UTC](https://community.auth0.com/t/error-400-for-post-user-registration-custom-action/78618 "2022-02-20T15:31:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andersco](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andersco/32/35347_2.png) [@andersco](https://community.auth0.com/u/andersco)\
**Post date:** [February 20, 2022, 3:31pm UTC](https://community.auth0.com/t/error-400-for-post-user-registration-custom-action/78618/1 "2022-02-20T15:31:18Z")

</div>

I would like to create a new user record in my app’s database following new user registration. I have created a custom action to achieve this. I have also added an endpoint in my app’s API for creating a new user and confirmed that the endpoint works.

However, when testing my custom action in Auth0, all I get is the following message: “Request failed with status code 400”. The action has been deployed and I have confirmed that signup works.

This is the current version of the action (please note that I will be adding metadata and security checks but for now I just want to get it working):

```auto
const axios = require("axios");

exports.onExecutePostUserRegistration = async (event) => {
   await axios.post("<API ENDPOINT>", { params: { email: event.preferred_username }});
};

```

The above values are based on the payload being sent by Auth0.

```auto
{
  "sub": "<SUB VALUE>",
  "nickname": "<EMAIL HANDLE>",
  "preferred_username": "<EMAIL>",
  "name": "<EMAIL>",
  "picture": "<GRAVATAR URL>",
  "updated_at": "2022-02-20T15:02:33.955Z",
  "https://www.jhipster.tech/roles": [] <--- no idea what this is
}

```

This is the complete Test results message:

```auto
Test Results
Error:
{
  "message": "Request failed with status code 400",
  "name": "Error"
}
Stats:
{
  "total_request_duration_ms": 385,
  "total_runtime_execution_duration_ms": 382,
  "runtime_processing_duration_ms": 8,
  "action_duration_ms": 311,
  "runtime_external_call_duration_ms": 63,
  "boot_duration_ms": 71,
  "network_duration_ms": 3
}

```

Any suggestions re. what I might be doing wrong and/or how I can debug this? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![andersco](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andersco/32/35347_2.png) [@andersco](https://community.auth0.com/u/andersco)\
**Post date:** [February 20, 2022, 8:17pm UTC](https://community.auth0.com/t/error-400-for-post-user-registration-custom-action/78618/2 "2022-02-20T20:17:13Z")

</div>

Figured out the problem. I was re-using the example provided in the docs and had not updated my payload object to match the expected object shape.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 21, 2022, 11:48am UTC](https://community.auth0.com/t/error-400-for-post-user-registration-custom-action/78618/3 "2022-02-21T11:48:58Z")

</div>

Wooohoo glad you have figured it out and thanks for sharing with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 22, 2022, 2:34pm UTC](https://community.auth0.com/t/error-400-for-post-user-registration-custom-action/78618/4 "2022-02-22T14:34:25Z")

</div>


