I want to add a user to the members group of a SP site. Unfortunately I always get the above mentioned error when I use the LoginName format that is documented in the API reference. When I use simple UPN or email, I get User not unique or not found.
I should propably have added that I come from an outside source, i.e. our Servicenow Instance and authenticate through an OAUTH token.
Here is the REST call:
Endpoint: http://xyz.sharepoint.com/sites/TestSite/_api/web/sitegroups(5)/users
Header:
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
Content:
{
'__metadata': { 'type': 'SP.User'},
'LoginName':'i:0#.f|membership|[email protected]'
}
Result:
{"error":{"code":"-2147024809, System.ArgumentException","message":{"lang":"en-US","value":"Value does not fall within the expected range."}}}
Any ideas are welcome.
Here are some shots from the setup (within Servicenow):



