Updating the New Universal login template using the management client throws 'The data must be an object'

Hi there,

trying to update the New Universal Login template using the management client like explained in the docs
https://auth0.github.io/node-auth0/module-management.ManagementClient.html#setBrandingUniversalLoginTemplate

Code snippet of my implementation*

exports.setBrandingNULTemplate = async() => {
  const management = new ManagementClient({
    token,
    domain
  });

  try {
    const result = await management.setBrandingUniversalLoginTemplate({ template: 'Hiyaa' });
    console.log('result', result);

  } catch(err) {
    console.log(err);
  }
}

*simplified for reasons.

This throws an error:
ArgumentError: The data must be an object

When requesting the current template it returns an object with {body: 'template'}, so I tried using body instead of template but computer says no. Also tried data.

What am I doing wrong?

:peace_symbol:

Hey there!

Judging by this one you’re doing everything correct:

Guessing where else the issue might be coming from

Could/did you verify that the endpoint works for you?

Sidenote: It does work when calling the endpoint as a plain request:

const options = {
    method: 'PUT',
    url: `https://${tenantUrl}/api/v2/branding/templates/universal-login`,
    headers: {authorization: `Bearer ${token}`, 'content-type': 'text/html'},
    data: 'Template data'
  };
1 Like

So I guess we’ve tracked the core reason of the issue which is the problem with the implementation in Node SDK. Can I ask you to raise it as a GitHub issue in the SDK repo and then share the link to it here so I can ping repo maintainers? Thank you!

Hi Konrad,

I’ve created the issue as requested.
management.setBrandingUniversalLoginTemplate returns ArgumentError: The data must be an object · Issue #623 · auth0/node-auth0 · GitHub

Found the issue. The example is incorrect. You MUST pass an empty object as params.

Asked the code team to update the examples.

1 Like

Perfect! Thanks a lot for sharing it with the rest of the community!