Error 400 for post user registration custom action

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):

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.

{
  "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:

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!

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.

1 Like

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