// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Users.Item.FollowedSites.Add;
using Microsoft.Graph.Models;
var requestBody = new AddPostRequestBody
{
Value = new List<Site>
{
new Site
{
Id = "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740",
},
new Site
{
Id = "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].FollowedSites.Add.PostAsAddPostResponseAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphusers "github.com/microsoftgraph/msgraph-sdk-go/users"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphusers.NewAddPostRequestBody()
site := graphmodels.NewSite()
id := "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740"
site.SetId(&id)
site1 := graphmodels.NewSite()
id := "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851"
site1.SetId(&id)
value := []graphmodels.Siteable {
site,
site1,
}
requestBody.SetValue(value)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
add, err := graphClient.Users().ByUserId("user-id").FollowedSites().Add().PostAsAddPostResponse(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.users.item.followedsites.add.AddPostRequestBody addPostRequestBody = new com.microsoft.graph.users.item.followedsites.add.AddPostRequestBody();
LinkedList<Site> value = new LinkedList<Site>();
Site site = new Site();
site.setId("contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740");
value.add(site);
Site site1 = new Site();
site1.setId("contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851");
value.add(site1);
addPostRequestBody.setValue(value);
var result = graphClient.users().byUserId("{user-id}").followedSites().add().post(addPostRequestBody);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.users.item.followedsites.add.add_post_request_body import AddPostRequestBody
from msgraph.generated.models.site import Site
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AddPostRequestBody(
value = [
Site(
id = "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740",
),
Site(
id = "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851",
),
],
)
result = await graph_client.users.by_user_id('user-id').followed_sites.add.post(request_body)
HTTP/1.1 207 Multi-Status
Content-type: application/json
{
"value": [
{
"id": "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,512a596e-90a1-49e3-9b48-bfa80bee8740",
"error": {
"@odata.type": "#oneDrive.error",
"code": "invalidRequest",
"message": "The site Id information that is provided in the request is incorrect",
"innerError": {
"code": "invalidRequest",
"errorType": "expected",
"message": "The site Id information that is provided in the request is incorrect",
"stackTrace": "",
"throwSite": ""
}
}
},
{
"id": "contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851",
"webUrl": "http://contoso.sharepoint.com/sites/SiteFollowed2",
"name": "SiteFollowed2",
"sharepointIds": {
"siteId": "da60e844-ba1d-49bc-b4d4-d5e36bae9019",
"siteUrl": "http://contoso.sharepoint.com/sites/SiteFollowed2",
"webId": "0271110f-634f-4300-a841-3a8a2e851851"
},
"siteCollection": {
"hostname": "contoso.sharepoint.com"
}
}
]
}