Optional. Set to one of the prefer values documented below.
Prefer header values
Name
Description
redeemSharingLink
If the shareIdOrEncodedSharingUrl is a sharing link, grant the caller durable access to the item
redeemSharingLinkIfNecessary
Same as redeemSharingLink, but access is only guaranteed to be granted for the duration of this request
redeemSharingLink should be considered equivalent to the caller navigating to the sharing link the browser (accepting the sharing gesture),
whereas redeemSharingLinkIfNecessary is intended for scenarios where the intention is simply to peek at the link's metadata.
Response
If successful, this method returns a 200 OK response code and a sharedDriveItem resource in the response body.
Example
Request
Here is an example of the request to retrieve a shared item:
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.SharesById("sharedDriveItem-id").Get(context.Background(), nil)
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestResult = $graphServiceClient->sharesById('sharedDriveItem-id')->get();
While the SharedDriveItem contains some useful information, most apps will want to directly access the shared DriveItem.
The SharedDriveItem resource includes a root and items relationships which can access content within the scope of the shared item.
Example (single file)
Request
By requesting the driveItem relationship, the DriveItem that was shared will be returned.
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.SharesById("sharedDriveItem-id").DriveItem().Get(context.Background(), nil)
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestResult = $graphServiceClient->sharesById('sharedDriveItem-id')->driveItem()->get();
By requesting the driveItem relationship and expanding the children collection, the DriveItem that was shared will be returned along with the files within the shared folder.
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestConfiguration = new DriveItemRequestBuilderGetRequestConfiguration();
$queryParameters = new DriveItemRequestBuilderGetQueryParameters();
$queryParameters->expand = ["children"];
$requestConfiguration->queryParameters = $queryParameters;
$requestResult = $graphServiceClient->sharesById('sharedDriveItem-id')->driveItem()->get($requestConfiguration);
Read the Error Responses topic for more information about
how errors are returned.
Remarks
For OneDrive for Business and SharePoint, the Shares API always requires authentication and cannot be used to access anonymously shared content without a user context.