创建已弃用的程序 ()
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
备注
访问评审 API 已弃用,将在 2023 年 5 月 19 日停止返回数据。 请使用 访问评审 。
在 Azure AD 访问评审 功能中,创建一个新的 程序 对象。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
ProgramControl.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
不支持。
已登录的用户还必须具有允许他们创建程序的目录角色。
HTTP 请求
POST /programs
名称
类型
说明
Authorization
string
持有者 {token}。必需。
请求正文
在请求正文中,提供 程序 对象的 JSON 表示形式。
下表显示了创建程序时所需的属性。
属性
类型
说明
displayName
String
程序的名称。
description
String
程序的说明。
响应
如果成功,此方法在响应正文中返回 201, Created 响应代码和 程序 对象。
示例
请求
在请求正文中,提供 程序 对象的 JSON 表示形式。
POST https://graph.microsoft.com/beta/programs
Content-type: application/json
{
"displayName": "testprogram3",
"description": "test description"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var program = new Program
{
DisplayName = "testprogram3",
Description = "test description"
};
await graphClient.Programs
.Request()
.AddAsync(program);
const options = {
authProvider,
};
const client = Client.init(options);
const program = {
displayName: 'testprogram3',
description: 'test description'
};
await client.api('/programs')
.version('beta')
.post(program);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/programs"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphProgram *program = [[MSGraphProgram alloc] init];
[program setDisplayName:@"testprogram3"];
[program setDescription:@"test description"];
NSError *error;
NSData *programData = [program getSerializedDataWithError:&error];
[urlRequest setHTTPBody:programData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Program program = new Program();
program.displayName = "testprogram3";
program.description = "test description";
graphClient.programs()
.buildRequest()
.post(program);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewProgram()
displayName := "testprogram3"
requestBody.SetDisplayName(&displayName)
description := "test description"
requestBody.SetDescription(&description)
result, err := graphClient.Programs().Post(requestBody)
Import-Module Microsoft.Graph.Identity.Governance
$params = @{
DisplayName = "testprogram3"
Description = "test description"
}
New-MgProgram -BodyParameter $params
响应
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-type: application/json
{
"id": "7e59d237-2fb0-4e5d-b7bb-d4f9f9129213",
"displayName": "testprogram3",
"description": "test description"
}
另请参阅