L’une des autorisations suivantes est nécessaire pour appeler cette API. Pour plus d’informations, notamment sur la façon de choisir les autorisations, voir Autorisations.
Type d’autorisation
Autorisations (de celle qui offre le plus de privilèges à celle qui en offre le moins)
Un 207 Multi-Status code de réponse indique que seules certaines des instances externalActivity ajoutées ont été traitées avec succès. L’appelant doit inspecter la charge utile de réponse, en examinant le champ d’erreur pour chaque externalActivityResult afin de déterminer pourquoi l’instance externalActivity n’a pas été traitée et quelle action peut être effectuée. Une null propriété d’erreur indique un externalActivityResult réussi.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.External.Connections.Item.Items.Item.MicrosoftGraphExternalConnectorsAddActivities;
using Microsoft.Graph.Models.ExternalConnectors;
var requestBody = new AddActivitiesPostRequestBody
{
Activities = new List<ExternalActivity>
{
new ExternalActivity
{
OdataType = "#microsoft.graph.externalConnectors.externalActivity",
Type = ExternalActivityType.Created,
StartDateTime = DateTimeOffset.Parse("2021-04-06T18:04:31.033Z"),
PerformedBy = new Identity
{
Type = IdentityType.User,
Id = "1f0c997e-99f7-43f1-8cca-086f8d42be8d",
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.External.Connections["{externalConnection-id}"].Items["{externalItem-id}"].MicrosoftGraphExternalConnectorsAddActivities.PostAsAddActivitiesPostResponseAsync(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"
graphexternal "github.com/microsoftgraph/msgraph-sdk-go/external"
graphmodelsexternalconnectors "github.com/microsoftgraph/msgraph-sdk-go/models/externalconnectors"
//other-imports
)
requestBody := graphexternal.NewAddActivitiesPostRequestBody()
externalActivity := graphmodelsexternalconnectors.NewExternalActivity()
type := graphmodels.CREATED_EXTERNALACTIVITYTYPE
externalActivity.SetType(&type)
startDateTime , err := time.Parse(time.RFC3339, "2021-04-06T18:04:31.033Z")
externalActivity.SetStartDateTime(&startDateTime)
performedBy := graphmodelsexternalconnectors.NewIdentity()
type := graphmodels.USER_IDENTITYTYPE
performedBy.SetType(&type)
id := "1f0c997e-99f7-43f1-8cca-086f8d42be8d"
performedBy.SetId(&id)
externalActivity.SetPerformedBy(performedBy)
activities := []graphmodelsexternalconnectors.ExternalActivityable {
externalActivity,
}
requestBody.SetActivities(activities)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
microsoftGraphExternalConnectorsAddActivities, err := graphClient.External().Connections().ByExternalConnectionId("externalConnection-id").Items().ByExternalItemId("externalItem-id").MicrosoftGraphExternalConnectorsAddActivities().PostAsAddActivitiesPostResponse(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.external.connections.item.items.item.microsoftgraphexternalconnectorsaddactivities.AddActivitiesPostRequestBody addActivitiesPostRequestBody = new com.microsoft.graph.external.connections.item.items.item.microsoftgraphexternalconnectorsaddactivities.AddActivitiesPostRequestBody();
LinkedList<com.microsoft.graph.models.externalconnectors.ExternalActivity> activities = new LinkedList<com.microsoft.graph.models.externalconnectors.ExternalActivity>();
com.microsoft.graph.models.externalconnectors.ExternalActivity externalActivity = new com.microsoft.graph.models.externalconnectors.ExternalActivity();
externalActivity.setOdataType("#microsoft.graph.externalConnectors.externalActivity");
externalActivity.setType(com.microsoft.graph.models.externalconnectors.ExternalActivityType.Created);
OffsetDateTime startDateTime = OffsetDateTime.parse("2021-04-06T18:04:31.033Z");
externalActivity.setStartDateTime(startDateTime);
com.microsoft.graph.models.externalconnectors.Identity performedBy = new com.microsoft.graph.models.externalconnectors.Identity();
performedBy.setType(com.microsoft.graph.models.externalconnectors.IdentityType.User);
performedBy.setId("1f0c997e-99f7-43f1-8cca-086f8d42be8d");
externalActivity.setPerformedBy(performedBy);
activities.add(externalActivity);
addActivitiesPostRequestBody.setActivities(activities);
var result = graphClient.external().connections().byExternalConnectionId("{externalConnection-id}").items().byExternalItemId("{externalItem-id}").microsoftGraphExternalConnectorsAddActivities().post(addActivitiesPostRequestBody);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\External\Connections\Item\Items\Item\MicrosoftGraphExternalConnectorsAddActivities\AddActivitiesPostRequestBody;
use Microsoft\Graph\Generated\Models\ExternalConnectors\ExternalActivity;
use Microsoft\Graph\Generated\Models\ExternalConnectors\ExternalActivityType;
use Microsoft\Graph\Generated\Models\ExternalConnectors\Identity;
use Microsoft\Graph\Generated\Models\ExternalConnectors\IdentityType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AddActivitiesPostRequestBody();
$activitiesExternalActivity1 = new ExternalActivity();
$activitiesExternalActivity1->setOdataType('#microsoft.graph.externalConnectors.externalActivity');
$activitiesExternalActivity1->setType(new ExternalActivityType('created'));
$activitiesExternalActivity1->setStartDateTime(new \DateTime('2021-04-06T18:04:31.033Z'));
$activitiesExternalActivity1PerformedBy = new Identity();
$activitiesExternalActivity1PerformedBy->setType(new IdentityType('user'));
$activitiesExternalActivity1PerformedBy->setId('1f0c997e-99f7-43f1-8cca-086f8d42be8d');
$activitiesExternalActivity1->setPerformedBy($activitiesExternalActivity1PerformedBy);
$activitiesArray []= $activitiesExternalActivity1;
$requestBody->setActivities($activitiesArray);
$result = $graphServiceClient->external()->connections()->byExternalConnectionId('externalConnection-id')->items()->byExternalItemId('externalItem-id')->microsoftGraphExternalConnectorsAddActivities()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.external.connections.item.items.item.microsoft_graph_external_connectors_add_activities.add_activities_post_request_body import AddActivitiesPostRequestBody
from msgraph.generated.models.external_connectors.external_activity import ExternalActivity
from msgraph.generated.models.external_activity_type import ExternalActivityType
from msgraph.generated.models.external_connectors.identity import Identity
from msgraph.generated.models.identity_type import IdentityType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AddActivitiesPostRequestBody(
activities = [
ExternalActivity(
odata_type = "#microsoft.graph.externalConnectors.externalActivity",
type = ExternalActivityType.Created,
start_date_time = "2021-04-06T18:04:31.033Z",
performed_by = Identity(
type = IdentityType.User,
id = "1f0c997e-99f7-43f1-8cca-086f8d42be8d",
),
),
],
)
result = await graph_client.external.connections.by_external_connection_id('externalConnection-id').items.by_external_item_id('externalItem-id').microsoft_graph_external_connectors_add_activities.post(request_body)