Create securityAction
-
- 2 minutes to read
-
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported.
Create a new securityAction object.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permission type |
Permissions (from least to most privileged) |
Delegated (work or school account) |
Not supported. |
Delegated (personal Microsoft account) |
Not supported. |
Application |
SecurityActions.ReadWrite.All |
HTTP request
POST /security/securityActions
Name |
Description |
Authorization |
Bearer {code} |
Request body
In the request body, supply a JSON representation of a securityAction object.
Response
If successful, this method returns 201 Created
response code and a securityAction object in the response body.
Examples
Request
The following is an example of the request.
POST https://graph.microsoft.com/beta/security/securityActions
Content-type: application/json
{
"name": "BlockIp",
"actionReason": "Test",
"parameters": [
{
"name": "IP",
"value": "1.2.3.4"
}
],
"vendorInformation": {
"provider": "Windows Defender ATP",
"vendor": "Microsoft"
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var securityAction = new SecurityAction
{
Name = "BlockIp",
ActionReason = "Test",
Parameters = new List<KeyValuePair>()
{
new KeyValuePair
{
Name = "IP",
Value = "1.2.3.4"
}
},
VendorInformation = new SecurityVendorInformation
{
Provider = "Windows Defender ATP",
Vendor = "Microsoft"
}
};
await graphClient.Security.SecurityActions
.Request()
.AddAsync(securityAction);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
const options = {
authProvider,
};
const client = Client.init(options);
const securityAction = {
name: "BlockIp",
actionReason: "Test",
parameters: [
{
name: "IP",
value: "1.2.3.4"
}
],
vendorInformation: {
provider: "Windows Defender ATP",
vendor: "Microsoft"
}
};
let res = await client.api('/security/securityActions')
.version('beta')
.post(securityAction);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/security/securityActions"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphSecurityAction *securityAction = [[MSGraphSecurityAction alloc] init];
[securityAction setName:@"BlockIp"];
[securityAction setActionReason:@"Test"];
NSMutableArray *parametersList = [[NSMutableArray alloc] init];
MSGraphKeyValuePair *parameters = [[MSGraphKeyValuePair alloc] init];
[parameters setName:@"IP"];
[parameters setValue:@"1.2.3.4"];
[parametersList addObject: parameters];
[securityAction setParameters:parametersList];
MSGraphSecurityVendorInformation *vendorInformation = [[MSGraphSecurityVendorInformation alloc] init];
[vendorInformation setProvider:@"Windows Defender ATP"];
[vendorInformation setVendor:@"Microsoft"];
[securityAction setVendorInformation:vendorInformation];
NSError *error;
NSData *securityActionData = [securityAction getSerializedDataWithError:&error];
[urlRequest setHTTPBody:securityActionData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
Response
The following is an example of the response.
Note
The response object shown here might be shortened for readability. All the properties will be returned from an actual call.
HTTP/1.1 201 Created
Content-type: application/json
{
"id" : "1234567890",
"status" : "notStarted",
"createdDateTime": "2019-01-10 12:23:23.33333",
"lastActionDateTime": "2019-01-10 12:23:23.33333",
"name": "blockIp",
"actionReason": "Test",
"errorInfo": null,
"vendorInformation": {
"provider": "Windows Defender ATP",
"providerVersion": null,
"subProvider": null,
"vendor": "Microsoft"
},
"parameters": [
{
"name": "IP",
"value": "1.2.3.4"
}
]
}