1

I'm using SharePoint Online and SharePoint REST API v1.

I realize that after a user is added to people column of a list manually, I can get user ID and add this user to a column by the API.

But I need to add users in my organization who are not added to my list.

How can I do this?

1 Answer 1

0

I think you are looking for EnsureUser method.

Checks whether the specified login name belongs to a valid user in the site. If the user doesn't exist, adds the user to the site.

Request example:

$.ajax({
  url: "http://<site url>/_api/web
    /ensureuser",
  type: "POST",
  data: "{ 'logonName': 'i:0#.f|membership|[email protected]' }",
  headers: {
    "X-RequestDigest": <form digest value>,
    "accept": "application/json;odata=verbose"
  },
  success: successHandler,
  error: errorHandler
});

This method will return user id in success function.

Additional References:

  1. Sharepoint 2013: EnsureUser via REST API
  2. Using REST, How can you add a user to the User Information List so that he/she has a user ID?
1
  • 1
    I was looking for this feature! Thank you!
    – decoy
    Commented Jul 20, 2021 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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