Hello,
I’m trying to add a user to Okta using the Okta API. I can do that using Postman, using the collection Users (Okta API), in the Create User folder, the Post method Create Activated User With Password.
I need to replicate that from my Javascript code, so I have been trying to do that using the following Ajax call:
var oktaParameters = {
"profile": [{ "firstName": "FirstNameValue", "lastName": "LastNameValue", "email": "t1@testEmail.com", "login": "t1@testEmail.com" }],
"credentials": [{ "password": { "value": "Password5!" }}]
};
$.ajax({
url: 'https://domain.okta.com/api/v1/users?activate=true',
type: 'POST',
crossDomain: true,
dataType: 'jsonp',
headers: { "Authorization": "Bearer" + "APITOKENVALUE" },
data: oktaParameters,
error: function (request, xhr, status, error) {
console.log('Error! request.responseText = ', request.responseText);
console.log('Error! xhr = ', xhr);
console.log('Error! status = ', status);
console.log('Error! error = ', error);
},
success: function (data) {
console.log('Success!');
}
});
This Ajax call is not working. I get a parser error in the xhr result, but it doesn’t contain more details that can help me understand what is the problem.
Please share how to do this.