I need to create user through JavaScript in SharePoint online while registering the user in aspx page using the same data as in the registration form on clicking of submit button


You can use below to create new user with EnsureUser method..

function ensureUser(accountName)
    var endpointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/ensureUser('" + encodeURIComponent(accountName) + "')";
    return $.ajax({       
       url: endpointUrl,   
       type: "POST",  
       contentType: "application/json;odata=verbose",
       headers: { 
          "Accept": "application/json;odata=verbose",
          "X-RequestDigest": $("#__REQUESTDIGEST").val()

var accountName = 'i:0#.f|membership|newuser@yourdomaim.com';
   console.log('New user created....');   
    console.log("Error creatign user----" + JSON.stringify(error));
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.