Using SharePoint REST API call SP.Web.ShareObject I try to share a document with another user of the same SharePoint site. The API call returns success response (Code 200) but can't update the share permission of the document. The response body contains following error message
SPWeb.ShareObjectInternal: no resolved users. ShareByEmailEnabled: False, CanPickerAcceptAnyEmail: False PickerInput: {"Key" : "i:0#.f|membership|[email protected]", "Description" : "[email protected]", "DisplayText" : "test user", "EntityType" : "User", "ProviderDisplayName" : "Tenant", "ProviderName" : "Tenant", "IsResolved" : true, "EntityData" : {"Title" : "", "MobilePhone" : "", "Department" : "", "Email" : "[email protected]"}, "MultipleMatches" : []}
This is the code I have used for sharing
$url = "https://tenant-my.sharepoint.com/personal/test_sharepointsite_info/_api/SP.Web.ShareObject";
$path = 'https://tenant-my.sharepoint.com/personal/test_sharepointsite_info/Documents/TestDoc.docx';
$data = array(
"url" => $path,
"peoplePickerInput" => '{"Key" : "i:0#.f|membership|[email protected]", "Description" : "[email protected]", "DisplayText" : "test user", "EntityType" : "User", "ProviderDisplayName" : "Tenant", "ProviderName" : "Tenant", "IsResolved" : true, "EntityData" : {"Title" : "", "MobilePhone" : "", "Department" : "", "Email" : "[email protected]"}, "MultipleMatches" : []}',
"roleValue" => "1073741827",
"groupId" => 0,
"propagateAcl" => false,
"sendEmail" => false,
"includeAnonymousLinkInEmail" => false,
"emailSubject" => "Subject",
"emailBody" => "Body"
);
$body = json_encode($data);
$content_length = strlen($body);
$header = array(
'X-RequestDigest' => $contextObject->d->GetContextWebInformation->FormDigestValue,
'accept'=>'application/json;odata=verbose',
'IF-MATCH' => '*',
'content-length' => $content_length
);
o365_performHttpRequestWithOAuth($url, array(), 'POST', $header, $body, 'application/json;odata=verbose');
What is wrong with the above code? why it returns the above error message?