
FlavelH.49645 (Customer) asked a question.
We required the "Security Question" MFA and I was trying to write the code to add the factor but keep receiving an error message:
- HTTP -1, Okta E0000003 (The request body was not well-formed.), ErrorId oaed7Qo2BLCQkm8YzCb8tF5KQ
Code:
- com.okta.sdk.resource.user.User newUser = UserBuilder.instance()<add_stuff_here>.setActive(false).buildAndCreate(oktaClient); Iterator<Factor> factors = newUser.listSupportedFactors().iterator(); while (factors.hasNext()) { Factor factor = factors.next(); if (factor instanceof SecurityQuestionFactor) { SecurityQuestionFactor sqf = (SecurityQuestionFactor) factor; SecurityQuestionFactorProfile profile = sqf.getProfile(); profile.setQuestion("name_of_first_plush_toy"); profile.setAnswer("Hardcoded"); sqf.setProfile(profile); newUser.addFactor(sqf); newUser.activate(false); }
I wasn't sure what part of the request body was not well-formed (newUser.addFactor(sqf); is the location of the exception)