nextLogin=changePassword for okta-sdk-nodejs

Hi,

I’m try to create a user with the following script.

  userManager.createUser =  async (user) => {
  oktaUser = {
    profile: {
      firstName: user.firstName,
      lastName: user.lastName,
      email:  user.email,
      login: user.email,
    },
    credentials : {
      password : "Blablabla2"
    },
    nextLogin: "changePassword"
}
  try {
    await client.createUser(oktaUser)
    return true
  } catch (e){
    console.log(e)
    return false
  }
}

I get the following error message:
[OktaApiError: Okta HTTP 400 E0000003 The request body was not well-formed… ] {
status: 400,
errorCode: ‘E0000003’,
errorSummary: ‘The request body was not well-formed.’,
errorCauses: [],
errorLink: ‘E0000003’,
errorId: ‘oae–S10pyCR_WWrDbI-j9FDQ’,
url: ‘https://xxx.okta.com/api/v1/users’,

How can I proceed?
Thanks!

Hi @gchicoye,

Try this code. It should work.

  userManager.createUser =  async (user) => {
  oktaUser = {
    profile: {
      firstName: user.firstName,
      lastName: user.lastName,
      email:  user.email,
      login: user.email,
    },
    credentials : {
      password : "Blablabla2"
    }
}
  try {
    let queryParameters = { activate : 'true' , nextLogin: 'changePassword' }
    await client.createUser(oktaUser, queryParameters)
    return true
  } catch (e){
    console.log(e)
    return false
  }
}