Namespace: microsoft.graph
Wichtig
Die APIs unter der /beta Version in Microsoft Graph können sich ändern. Die Verwendung dieser APIs in Produktionsanwendungen wird nicht unterstützt. Um festzustellen, ob eine API in v1.0 verfügbar ist, verwenden Sie die Version Selektor.
Hinzufügen eines Benutzers zu einer Schule.
Diese API ist in den folgenden nationalen Cloudbereitstellungen verfügbar.
| Weltweiter Service |
US Government L4 |
US Government L5 (DOD) |
China, betrieben von 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Berechtigungen
Wählen Sie die Berechtigungen aus, die für diese API als am wenigsten privilegiert markiert sind. Verwenden Sie eine höhere Berechtigung oder Berechtigungen nur, wenn Ihre App dies erfordert. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
| Berechtigungstyp |
Berechtigungen mit den geringsten Berechtigungen |
Berechtigungen mit höheren Berechtigungen |
| Delegiert (Geschäfts-, Schul- oder Unikonto) |
Nicht unterstützt |
Nicht unterstützt |
| Delegiert (persönliches Microsoft-Konto) |
Nicht unterstützt |
Nicht unterstützt |
| Anwendung |
EduRoster.ReadWrite.All |
Nicht verfügbar. |
HTTP-Anforderung
POST /education/schools/{id}/users/$ref
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung eines educationUser-Objekts an.
Antwort
Wenn die Methode erfolgreich verläuft, werden der Antwortcode 204 No Content und ein educationClass-Objekt im Antworttext zurückgegeben.
Beispiel
Anforderung
Das folgende Beispiel zeigt eine Anfrage.
POST https://graph.microsoft.com/beta/education/schools/{id}/users/$ref
Content-type: application/json
{
"@odata.id":"https://graph.microsoft.com/beta/education/users/14008"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new ReferenceCreate
{
OdataId = "https://graph.microsoft.com/beta/education/users/14008",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Education.Schools["{educationSchool-id}"].Users.Ref.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewReferenceCreate()
odataId := "https://graph.microsoft.com/beta/education/users/14008"
requestBody.SetOdataId(&odataId)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Education().Schools().ByEducationSchoolId("educationSchool-id").Users().Ref().Post(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.beta.models.ReferenceCreate referenceCreate = new com.microsoft.graph.beta.models.ReferenceCreate();
referenceCreate.setOdataId("https://graph.microsoft.com/beta/education/users/14008");
graphClient.education().schools().byEducationSchoolId("{educationSchool-id}").users().ref().post(referenceCreate);
const options = {
authProvider,
};
const client = Client.init(options);
const educationUser = {
'@odata.id':'https://graph.microsoft.com/beta/education/users/14008'
};
await client.api('/education/schools/{id}/users/$ref')
.version('beta')
.post(educationUser);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\ReferenceCreate;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ReferenceCreate();
$requestBody->setOdataId('https://graph.microsoft.com/beta/education/users/14008');
$graphServiceClient->education()->schools()->byEducationSchoolId('educationSchool-id')->users()->ref()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Education
$params = @{
"@odata.id" = "https://graph.microsoft.com/beta/education/users/14008"
}
New-MgBetaEducationSchoolUserByRef -EducationSchoolId $educationSchoolId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.reference_create import ReferenceCreate
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ReferenceCreate(
odata_id = "https://graph.microsoft.com/beta/education/users/14008",
)
await graph_client.education.schools.by_education_school_id('educationSchool-id').users.ref.post(request_body)
Antwort
Das folgende Beispiel zeigt die Antwort.
HTTP/1.1 204 No Content