Use este método para crear cualquier tipo de actividad.
Nota: Un proveedor solo puede administrar las actividades del curso de aprendizaje cuando isCourseAcitvitySyncEnabled está establecido en true. Para actualizar el valor, use el método Update learningProvider .
Elija el permiso o los permisos marcados como con privilegios mínimos para esta API. Use un permiso o permisos con privilegios superiores solo si la aplicación lo requiere. Para obtener más información sobre los permisos delegados y de aplicación, consulte Tipos de permisos. Para obtener más información sobre estos permisos, consulte la referencia de permisos.
Tipo de permiso
Permisos con privilegios mínimos
Permisos con privilegios más altos
Delegado (cuenta profesional o educativa)
No admitida.
No admitida.
Delegado (cuenta personal de Microsoft)
No admitida.
No admitida.
Aplicación
LearningAssignedCourse.ReadWrite.All
LearningSelfInitiatedCourse.ReadWrite.All
Solicitud HTTP
POST /employeeExperience/learningProviders/{registrationId}/learningCourseActivities
Si no se realiza correctamente, este método devuelve una de las respuestas siguientes:
Escenario
Código HTTP
Código
Mensaje
Detalles
Prohibido (Forbidden)
403
Prohibido (Forbidden)
No tiene un plan de servicio adecuado para esta solicitud.
Solicitud incorrecta
400
badRequest
Este proveedor no está habilitado para el inquilino determinado.
Solicitud incorrecta
400
badRequest
Se produjo un problema con la solicitud. Asegúrese de que el identificador de registro especificado es válido o registrado para el inquilino.
Error interno del servidor.
500
internalServerError
Error interno del servidor.
Solicitud limitada
429
tooManyRequests
{"code": "tooManyRequests","message": "Retry after {noOfMinutes} minutes"}.
Servicio no disponible
503
serviceUnavailable
{"code": "serviceUnavailable","message": "Retry after {noOfMinutes} minutes"}.
Error en varias validaciones de campos
400
badRequest
badRequest
{"code": "badRequest","message": "Input field {fieldName}shouldn't be empty"}, {"code": "badRequest","message": "Input field {fieldName} is required"}, {"code": "badRequest","message": "Input field {fieldName}length exceeded than {expectedLength}"}.
Prohibido (Forbidden)
403
El proveedor no es válido para crear la actividad del curso para el contenido de aprendizaje determinado.
Cuando registrationId/learningProviderId no coincide con el proveedor con el que se crea learningContent.
Prohibido (Forbidden)
403
La licencia de usuario no es válida para realizar la operación.
Cuando el usuario para el que se crea la asignación no tiene una licencia Premium.
Ejemplos
Ejemplo 1: Creación de una actividad de curso de aprendizaje asignada
En el ejemplo siguiente se muestra cómo crear una actividad learningAssignment .
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new LearningAssignment
{
OdataType = "#microsoft.graph.learningAssignment",
AssignedDateTime = DateTimeOffset.Parse("2021-05-11T22:57:17+00:00"),
AssignmentType = AssignmentType.Required,
AssignerUserId = "cea1684d-57dc-438d-a9d1-e666ec1a7f3d",
CompletedDateTime = null,
CompletionPercentage = 20,
DueDateTime = new DateTimeTimeZone
{
DateTime = "2022-09-22T16:05:00.0000000",
TimeZone = "UTC",
},
ExternalCourseActivityId = "12a2228a-e020-11ec-9d64-0242ac120002",
LearningContentId = "57baf9dc-e020-11ec-9d64-0242ac120002",
LearningProviderId = "01e8f81b-3060-4dec-acf0-0389665a0a38",
LearnerUserId = "7ba2228a-e020-11ec-9d64-0242ac120002",
Notes = new ItemBody
{
ContentType = BodyType.Text,
Content = "required assignment added for user",
},
Status = CourseStatus.NotStarted,
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.EmployeeExperience.LearningProviders["{learningProvider-id}"].LearningCourseActivities.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
LearningAssignment learningCourseActivity = new LearningAssignment();
learningCourseActivity.setOdataType("#microsoft.graph.learningAssignment");
OffsetDateTime assignedDateTime = OffsetDateTime.parse("2021-05-11T22:57:17+00:00");
learningCourseActivity.setAssignedDateTime(assignedDateTime);
learningCourseActivity.setAssignmentType(AssignmentType.Required);
learningCourseActivity.setAssignerUserId("cea1684d-57dc-438d-a9d1-e666ec1a7f3d");
learningCourseActivity.setCompletedDateTime(null);
learningCourseActivity.setCompletionPercentage(20);
DateTimeTimeZone dueDateTime = new DateTimeTimeZone();
dueDateTime.setDateTime("2022-09-22T16:05:00.0000000");
dueDateTime.setTimeZone("UTC");
learningCourseActivity.setDueDateTime(dueDateTime);
learningCourseActivity.setExternalCourseActivityId("12a2228a-e020-11ec-9d64-0242ac120002");
learningCourseActivity.setLearningContentId("57baf9dc-e020-11ec-9d64-0242ac120002");
learningCourseActivity.setLearningProviderId("01e8f81b-3060-4dec-acf0-0389665a0a38");
learningCourseActivity.setLearnerUserId("7ba2228a-e020-11ec-9d64-0242ac120002");
ItemBody notes = new ItemBody();
notes.setContentType(BodyType.Text);
notes.setContent("required assignment added for user");
learningCourseActivity.setNotes(notes);
learningCourseActivity.setStatus(CourseStatus.NotStarted);
LearningCourseActivity result = graphClient.employeeExperience().learningProviders().byLearningProviderId("{learningProvider-id}").learningCourseActivities().post(learningCourseActivity);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\LearningAssignment;
use Microsoft\Graph\Generated\Models\AssignmentType;
use Microsoft\Graph\Generated\Models\DateTimeTimeZone;
use Microsoft\Graph\Generated\Models\ItemBody;
use Microsoft\Graph\Generated\Models\BodyType;
use Microsoft\Graph\Generated\Models\CourseStatus;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new LearningAssignment();
$requestBody->setOdataType('#microsoft.graph.learningAssignment');
$requestBody->setAssignedDateTime(new \DateTime('2021-05-11T22:57:17+00:00'));
$requestBody->setAssignmentType(new AssignmentType('required'));
$requestBody->setAssignerUserId('cea1684d-57dc-438d-a9d1-e666ec1a7f3d');
$requestBody->setCompletedDateTime(null);
$requestBody->setCompletionPercentage(20);
$dueDateTime = new DateTimeTimeZone();
$dueDateTime->setDateTime('2022-09-22T16:05:00.0000000');
$dueDateTime->setTimeZone('UTC');
$requestBody->setDueDateTime($dueDateTime);
$requestBody->setExternalCourseActivityId('12a2228a-e020-11ec-9d64-0242ac120002');
$requestBody->setLearningContentId('57baf9dc-e020-11ec-9d64-0242ac120002');
$requestBody->setLearningProviderId('01e8f81b-3060-4dec-acf0-0389665a0a38');
$requestBody->setLearnerUserId('7ba2228a-e020-11ec-9d64-0242ac120002');
$notes = new ItemBody();
$notes->setContentType(new BodyType('text'));
$notes->setContent('required assignment added for user');
$requestBody->setNotes($notes);
$requestBody->setStatus(new CourseStatus('notStarted'));
$result = $graphServiceClient->employeeExperience()->learningProviders()->byLearningProviderId('learningProvider-id')->learningCourseActivities()->post($requestBody)->wait();
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new LearningSelfInitiatedCourse
{
OdataType = "#microsoft.graph.learningSelfInitiatedCourse",
CompletedDateTime = null,
CompletionPercentage = 20,
ExternalCourseActivityId = "12a2228a-e020-11ec-9d64-0242ac120002",
LearningContentId = "57baf9dc-e020-11ec-9d64-0242ac120002",
LearnerUserId = "7ba2228a-e020-11ec-9d64-0242ac120002",
StartedDateTime = DateTimeOffset.Parse("2021-05-21T22:57:17+00:00"),
Status = CourseStatus.InProgress,
};
// To initialize your graphClient, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.EmployeeExperience.LearningProviders["{learningProvider-id}"].LearningCourseActivities.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
LearningSelfInitiatedCourse learningCourseActivity = new LearningSelfInitiatedCourse();
learningCourseActivity.setOdataType("#microsoft.graph.learningSelfInitiatedCourse");
learningCourseActivity.setCompletedDateTime(null);
learningCourseActivity.setCompletionPercentage(20);
learningCourseActivity.setExternalCourseActivityId("12a2228a-e020-11ec-9d64-0242ac120002");
learningCourseActivity.setLearningContentId("57baf9dc-e020-11ec-9d64-0242ac120002");
learningCourseActivity.setLearnerUserId("7ba2228a-e020-11ec-9d64-0242ac120002");
OffsetDateTime startedDateTime = OffsetDateTime.parse("2021-05-21T22:57:17+00:00");
learningCourseActivity.setStartedDateTime(startedDateTime);
learningCourseActivity.setStatus(CourseStatus.InProgress);
LearningCourseActivity result = graphClient.employeeExperience().learningProviders().byLearningProviderId("{learningProvider-id}").learningCourseActivities().post(learningCourseActivity);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.learning_self_initiated_course import LearningSelfInitiatedCourse
from msgraph.generated.models.course_status import CourseStatus
# To initialize your graph_client, see https://video2.skills-academy.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = LearningSelfInitiatedCourse(
odata_type = "#microsoft.graph.learningSelfInitiatedCourse",
completed_date_time = None,
completion_percentage = 20,
external_course_activity_id = "12a2228a-e020-11ec-9d64-0242ac120002",
learning_content_id = "57baf9dc-e020-11ec-9d64-0242ac120002",
learner_user_id = "7ba2228a-e020-11ec-9d64-0242ac120002",
started_date_time = "2021-05-21T22:57:17+00:00",
status = CourseStatus.InProgress,
)
result = await graph_client.employee_experience.learning_providers.by_learning_provider_id('learningProvider-id').learning_course_activities.post(request_body)