Remove role from user API not getting body

Hello. My request to Management API (Remove Roles from User) is not getting the body/data from the request I made.
My code:

  const removeRole = this.httpService
  .delete(`${auth0API}users/${userId}/roles`, {
    headers: { Authorization: `Bearer ${token}` },
    data: { data: {
      roles: [`${role}`],
  .pipe(map(res =>
  .catch(err => {
    throw new Error(err);

Response from auth0:

data: {
  statusCode: 400,
  error: 'Bad Request',
  message: "Payload validation error: 'Expected type object but found type null'.",
  errorCode: 'invalid_body'

Delete method from HttpService/Axios only takes two parameters. So I put it in
Hope to help me soon.

Hi @gab.estremos,

Welcome to the Community!

Have you considered using our node library? It will greatly simplify this type of request.

The request would look like this:

const ManagementClient = require('auth0').ManagementClient;

const management = new ManagementClient({
  token: '{YOUR_API_V2_TOKEN}',
  domain: '{YOUR_ACCOUNT}'

const params =  { id : 'USER_ID'};
const data = { "roles" : ["roleId1", "roleID2"]};

management.users.removeRoles(params, data, function (err, user) {
  if (err) {
    // Handle error.

  // roles removed.

Thanks for this @dan.woda. It works!

1 Like

Glad it’s working for you. Let me know if you have any other questions!

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