Create a new threat assessment request.
A threat assessment request can be one of the following types:
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
❌ |
❌ |
❌ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
ThreatAssessment.ReadWrite.All |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Not supported. |
Not supported. |
HTTP request
POST /informationProtection/threatAssessmentRequests
Request body
In the request body, supply a JSON representation of a threatAssessmentRequest object.
Response
If successful, this method returns a 201 Created
response code and a new threatAssessmentRequest object in the response body.
Examples
Example 1: Create a mail assessment request
Request
The following example shows a request.
POST https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests
Content-type: application/json
{
"@odata.type": "#microsoft.graph.mailAssessmentRequest",
"recipientEmail": "tifc@contoso.com",
"expectedAssessment": "block",
"category": "spam",
"messageUri": "https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt="
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new MailAssessmentRequest
{
OdataType = "#microsoft.graph.mailAssessmentRequest",
RecipientEmail = "tifc@contoso.com",
ExpectedAssessment = ThreatExpectedAssessment.Block,
Category = ThreatCategory.Spam,
MessageUri = "https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt=",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.InformationProtection.ThreatAssessmentRequests.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc information-protection threat-assessment-requests create --body '{\
"@odata.type": "#microsoft.graph.mailAssessmentRequest",\
"recipientEmail": "tifc@contoso.com",\
"expectedAssessment": "block",\
"category": "spam",\
"messageUri": "https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt="\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewThreatAssessmentRequest()
recipientEmail := "tifc@contoso.com"
requestBody.SetRecipientEmail(&recipientEmail)
expectedAssessment := graphmodels.BLOCK_THREATEXPECTEDASSESSMENT
requestBody.SetExpectedAssessment(&expectedAssessment)
category := graphmodels.SPAM_THREATCATEGORY
requestBody.SetCategory(&category)
messageUri := "https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt="
requestBody.SetMessageUri(&messageUri)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
threatAssessmentRequests, err := graphClient.InformationProtection().ThreatAssessmentRequests().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
MailAssessmentRequest threatAssessmentRequest = new MailAssessmentRequest();
threatAssessmentRequest.setOdataType("#microsoft.graph.mailAssessmentRequest");
threatAssessmentRequest.setRecipientEmail("tifc@contoso.com");
threatAssessmentRequest.setExpectedAssessment(ThreatExpectedAssessment.Block);
threatAssessmentRequest.setCategory(ThreatCategory.Spam);
threatAssessmentRequest.setMessageUri("https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt=");
ThreatAssessmentRequest result = graphClient.informationProtection().threatAssessmentRequests().post(threatAssessmentRequest);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const threatAssessmentRequest = {
'@odata.type': '#microsoft.graph.mailAssessmentRequest',
recipientEmail: 'tifc@contoso.com',
expectedAssessment: 'block',
category: 'spam',
messageUri: 'https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt='
};
await client.api('/informationProtection/threatAssessmentRequests')
.post(threatAssessmentRequest);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\MailAssessmentRequest;
use Microsoft\Graph\Generated\Models\ThreatExpectedAssessment;
use Microsoft\Graph\Generated\Models\ThreatCategory;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new MailAssessmentRequest();
$requestBody->setOdataType('#microsoft.graph.mailAssessmentRequest');
$requestBody->setRecipientEmail('tifc@contoso.com');
$requestBody->setExpectedAssessment(new ThreatExpectedAssessment('block'));
$requestBody->setCategory(new ThreatCategory('spam'));
$requestBody->setMessageUri('https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt=');
$result = $graphServiceClient->informationProtection()->threatAssessmentRequests()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.mailAssessmentRequest"
recipientEmail = "tifc@contoso.com"
expectedAssessment = "block"
category = "spam"
messageUri = "https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt="
}
New-MgInformationProtectionThreatAssessmentRequest -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.mail_assessment_request import MailAssessmentRequest
from msgraph.generated.models.threat_expected_assessment import ThreatExpectedAssessment
from msgraph.generated.models.threat_category import ThreatCategory
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = MailAssessmentRequest(
odata_type = "#microsoft.graph.mailAssessmentRequest",
recipient_email = "tifc@contoso.com",
expected_assessment = ThreatExpectedAssessment.Block,
category = ThreatCategory.Spam,
message_uri = "https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt=",
)
result = await graph_client.information_protection.threat_assessment_requests.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#informationProtection/threatAssessmentRequests/$entity",
"@odata.type": "#microsoft.graph.mailAssessmentRequest",
"id": "49c5ef5b-1f65-444a-e6b9-08d772ea2059",
"createdDateTime": "2019-11-27T03:30:18.6890937Z",
"contentType": "mail",
"expectedAssessment": "block",
"category": "spam",
"status": "pending",
"requestSource": "administrator",
"recipientEmail": "tifc@contoso.com",
"destinationRoutingReason": "notJunk",
"messageUri": "https://graph.microsoft.com/v1.0/users/c52ce8db-3e4b-4181-93c4-7d6b6bffaf60/messages/AAMkADU3MWUxOTU0LWNlOTEt=",
"createdBy": {
"user": {
"id": "c52ce8db-3e4b-4181-93c4-7d6b6bffaf60",
"displayName": "Ronald Admin"
}
}
}
Example 2: Create an email assessment request
Request
The following example shows a request.
POST https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests
Content-type: application/json
{
"@odata.type": "#microsoft.graph.emailFileAssessmentRequest",
"recipientEmail": "tifc@contoso.com",
"expectedAssessment": "block",
"category": "malware",
"contentData": "UmVjZWl2ZWQ6IGZyb20gTVcyUFIwME1CMDMxNC5uYW1wcmQwMC....."
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new EmailFileAssessmentRequest
{
OdataType = "#microsoft.graph.emailFileAssessmentRequest",
RecipientEmail = "tifc@contoso.com",
ExpectedAssessment = ThreatExpectedAssessment.Block,
Category = ThreatCategory.Malware,
ContentData = "UmVjZWl2ZWQ6IGZyb20gTVcyUFIwME1CMDMxNC5uYW1wcmQwMC.....",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.InformationProtection.ThreatAssessmentRequests.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc information-protection threat-assessment-requests create --body '{\
"@odata.type": "#microsoft.graph.emailFileAssessmentRequest",\
"recipientEmail": "tifc@contoso.com",\
"expectedAssessment": "block",\
"category": "malware",\
"contentData": "UmVjZWl2ZWQ6IGZyb20gTVcyUFIwME1CMDMxNC5uYW1wcmQwMC....."\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewThreatAssessmentRequest()
recipientEmail := "tifc@contoso.com"
requestBody.SetRecipientEmail(&recipientEmail)
expectedAssessment := graphmodels.BLOCK_THREATEXPECTEDASSESSMENT
requestBody.SetExpectedAssessment(&expectedAssessment)
category := graphmodels.MALWARE_THREATCATEGORY
requestBody.SetCategory(&category)
contentData := "UmVjZWl2ZWQ6IGZyb20gTVcyUFIwME1CMDMxNC5uYW1wcmQwMC....."
requestBody.SetContentData(&contentData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
threatAssessmentRequests, err := graphClient.InformationProtection().ThreatAssessmentRequests().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
EmailFileAssessmentRequest threatAssessmentRequest = new EmailFileAssessmentRequest();
threatAssessmentRequest.setOdataType("#microsoft.graph.emailFileAssessmentRequest");
threatAssessmentRequest.setRecipientEmail("tifc@contoso.com");
threatAssessmentRequest.setExpectedAssessment(ThreatExpectedAssessment.Block);
threatAssessmentRequest.setCategory(ThreatCategory.Malware);
threatAssessmentRequest.setContentData("UmVjZWl2ZWQ6IGZyb20gTVcyUFIwME1CMDMxNC5uYW1wcmQwMC.....");
ThreatAssessmentRequest result = graphClient.informationProtection().threatAssessmentRequests().post(threatAssessmentRequest);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const threatAssessmentRequest = {
'@odata.type': '#microsoft.graph.emailFileAssessmentRequest',
recipientEmail: 'tifc@contoso.com',
expectedAssessment: 'block',
category: 'malware',
contentData: 'UmVjZWl2ZWQ6IGZyb20gTVcyUFIwME1CMDMxNC5uYW1wcmQwMC.....'
};
await client.api('/informationProtection/threatAssessmentRequests')
.post(threatAssessmentRequest);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\EmailFileAssessmentRequest;
use Microsoft\Graph\Generated\Models\ThreatExpectedAssessment;
use Microsoft\Graph\Generated\Models\ThreatCategory;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new EmailFileAssessmentRequest();
$requestBody->setOdataType('#microsoft.graph.emailFileAssessmentRequest');
$requestBody->setRecipientEmail('tifc@contoso.com');
$requestBody->setExpectedAssessment(new ThreatExpectedAssessment('block'));
$requestBody->setCategory(new ThreatCategory('malware'));
$requestBody->setContentData('UmVjZWl2ZWQ6IGZyb20gTVcyUFIwME1CMDMxNC5uYW1wcmQwMC.....');
$result = $graphServiceClient->informationProtection()->threatAssessmentRequests()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.emailFileAssessmentRequest"
recipientEmail = "tifc@contoso.com"
expectedAssessment = "block"
category = "malware"
contentData = "UmVjZWl2ZWQ6IGZyb20gTVcyUFIwME1CMDMxNC5uYW1wcmQwMC....."
}
New-MgInformationProtectionThreatAssessmentRequest -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.email_file_assessment_request import EmailFileAssessmentRequest
from msgraph.generated.models.threat_expected_assessment import ThreatExpectedAssessment
from msgraph.generated.models.threat_category import ThreatCategory
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = EmailFileAssessmentRequest(
odata_type = "#microsoft.graph.emailFileAssessmentRequest",
recipient_email = "tifc@contoso.com",
expected_assessment = ThreatExpectedAssessment.Block,
category = ThreatCategory.Malware,
content_data = "UmVjZWl2ZWQ6IGZyb20gTVcyUFIwME1CMDMxNC5uYW1wcmQwMC.....",
)
result = await graph_client.information_protection.threat_assessment_requests.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#informationProtection/threatAssessmentRequests/$entity",
"@odata.type": "#microsoft.graph.emailFileAssessmentRequest",
"id": "ab2ad9b3-2213-4091-ae0c-08d76ddbcacf",
"createdDateTime": "2019-11-20T17:05:06.4088076Z",
"contentType": "mail",
"expectedAssessment": "block",
"category": "malware",
"status": "completed",
"requestSource": "administrator",
"recipientEmail": "tifc@contoso.com",
"destinationRoutingReason": "notJunk",
"contentData": "",
"createdBy": {
"user": {
"id": "c52ce8db-3e4b-4181-93c4-7d6b6bffaf60",
"displayName": "Ronald Admin"
}
}
}
Example 3: Create a file assessment request
Request
The following example shows a request.
POST https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests
Content-type: application/json
{
"@odata.type": "#microsoft.graph.fileAssessmentRequest",
"expectedAssessment": "block",
"category": "malware",
"fileName": "test.txt",
"contentData": "VGhpcyBpcyBhIHRlc3QgZmlsZQ=="
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new FileAssessmentRequest
{
OdataType = "#microsoft.graph.fileAssessmentRequest",
ExpectedAssessment = ThreatExpectedAssessment.Block,
Category = ThreatCategory.Malware,
FileName = "test.txt",
ContentData = "VGhpcyBpcyBhIHRlc3QgZmlsZQ==",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.InformationProtection.ThreatAssessmentRequests.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc information-protection threat-assessment-requests create --body '{\
"@odata.type": "#microsoft.graph.fileAssessmentRequest",\
"expectedAssessment": "block",\
"category": "malware",\
"fileName": "test.txt",\
"contentData": "VGhpcyBpcyBhIHRlc3QgZmlsZQ=="\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewThreatAssessmentRequest()
expectedAssessment := graphmodels.BLOCK_THREATEXPECTEDASSESSMENT
requestBody.SetExpectedAssessment(&expectedAssessment)
category := graphmodels.MALWARE_THREATCATEGORY
requestBody.SetCategory(&category)
fileName := "test.txt"
requestBody.SetFileName(&fileName)
contentData := "VGhpcyBpcyBhIHRlc3QgZmlsZQ=="
requestBody.SetContentData(&contentData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
threatAssessmentRequests, err := graphClient.InformationProtection().ThreatAssessmentRequests().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
FileAssessmentRequest threatAssessmentRequest = new FileAssessmentRequest();
threatAssessmentRequest.setOdataType("#microsoft.graph.fileAssessmentRequest");
threatAssessmentRequest.setExpectedAssessment(ThreatExpectedAssessment.Block);
threatAssessmentRequest.setCategory(ThreatCategory.Malware);
threatAssessmentRequest.setFileName("test.txt");
threatAssessmentRequest.setContentData("VGhpcyBpcyBhIHRlc3QgZmlsZQ==");
ThreatAssessmentRequest result = graphClient.informationProtection().threatAssessmentRequests().post(threatAssessmentRequest);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const threatAssessmentRequest = {
'@odata.type': '#microsoft.graph.fileAssessmentRequest',
expectedAssessment: 'block',
category: 'malware',
fileName: 'test.txt',
contentData: 'VGhpcyBpcyBhIHRlc3QgZmlsZQ=='
};
await client.api('/informationProtection/threatAssessmentRequests')
.post(threatAssessmentRequest);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\FileAssessmentRequest;
use Microsoft\Graph\Generated\Models\ThreatExpectedAssessment;
use Microsoft\Graph\Generated\Models\ThreatCategory;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new FileAssessmentRequest();
$requestBody->setOdataType('#microsoft.graph.fileAssessmentRequest');
$requestBody->setExpectedAssessment(new ThreatExpectedAssessment('block'));
$requestBody->setCategory(new ThreatCategory('malware'));
$requestBody->setFileName('test.txt');
$requestBody->setContentData('VGhpcyBpcyBhIHRlc3QgZmlsZQ==');
$result = $graphServiceClient->informationProtection()->threatAssessmentRequests()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.fileAssessmentRequest"
expectedAssessment = "block"
category = "malware"
fileName = "test.txt"
contentData = "VGhpcyBpcyBhIHRlc3QgZmlsZQ=="
}
New-MgInformationProtectionThreatAssessmentRequest -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.file_assessment_request import FileAssessmentRequest
from msgraph.generated.models.threat_expected_assessment import ThreatExpectedAssessment
from msgraph.generated.models.threat_category import ThreatCategory
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = FileAssessmentRequest(
odata_type = "#microsoft.graph.fileAssessmentRequest",
expected_assessment = ThreatExpectedAssessment.Block,
category = ThreatCategory.Malware,
file_name = "test.txt",
content_data = "VGhpcyBpcyBhIHRlc3QgZmlsZQ==",
)
result = await graph_client.information_protection.threat_assessment_requests.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#informationProtection/threatAssessmentRequests/$entity",
"@odata.type": "#microsoft.graph.fileAssessmentRequest",
"id": "18406a56-7209-4720-a250-08d772fccdaa",
"createdDateTime": "2019-11-27T05:44:00.4051536Z",
"contentType": "file",
"expectedAssessment": "block",
"category": "malware",
"status": "completed",
"requestSource": "administrator",
"fileName": "b3d5b715-4b88-4bbb-b0ae-9a9281a3f18a.csv",
"contentData": "",
"createdBy": {
"user": {
"id": "c52ce8db-3e4b-4181-93c4-7d6b6bffaf60",
"displayName": "Ronald Admin"
}
}
}
Example 4: Create an url assessment request
Request
The following example shows a request.
POST https://graph.microsoft.com/v1.0/informationProtection/threatAssessmentRequests
Content-type: application/json
{
"@odata.type": "#microsoft.graph.urlAssessmentRequest",
"url": "http://test.com",
"expectedAssessment": "block",
"category": "phishing"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new UrlAssessmentRequest
{
OdataType = "#microsoft.graph.urlAssessmentRequest",
Url = "http://test.com",
ExpectedAssessment = ThreatExpectedAssessment.Block,
Category = ThreatCategory.Phishing,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.InformationProtection.ThreatAssessmentRequests.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc information-protection threat-assessment-requests create --body '{\
"@odata.type": "#microsoft.graph.urlAssessmentRequest",\
"url": "http://test.com",\
"expectedAssessment": "block",\
"category": "phishing"\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// 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"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewThreatAssessmentRequest()
url := "http://test.com"
requestBody.SetUrl(&url)
expectedAssessment := graphmodels.BLOCK_THREATEXPECTEDASSESSMENT
requestBody.SetExpectedAssessment(&expectedAssessment)
category := graphmodels.PHISHING_THREATCATEGORY
requestBody.SetCategory(&category)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
threatAssessmentRequests, err := graphClient.InformationProtection().ThreatAssessmentRequests().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
UrlAssessmentRequest threatAssessmentRequest = new UrlAssessmentRequest();
threatAssessmentRequest.setOdataType("#microsoft.graph.urlAssessmentRequest");
threatAssessmentRequest.setUrl("http://test.com");
threatAssessmentRequest.setExpectedAssessment(ThreatExpectedAssessment.Block);
threatAssessmentRequest.setCategory(ThreatCategory.Phishing);
ThreatAssessmentRequest result = graphClient.informationProtection().threatAssessmentRequests().post(threatAssessmentRequest);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const threatAssessmentRequest = {
'@odata.type': '#microsoft.graph.urlAssessmentRequest',
url: 'http://test.com',
expectedAssessment: 'block',
category: 'phishing'
};
await client.api('/informationProtection/threatAssessmentRequests')
.post(threatAssessmentRequest);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\UrlAssessmentRequest;
use Microsoft\Graph\Generated\Models\ThreatExpectedAssessment;
use Microsoft\Graph\Generated\Models\ThreatCategory;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new UrlAssessmentRequest();
$requestBody->setOdataType('#microsoft.graph.urlAssessmentRequest');
$requestBody->setUrl('http://test.com');
$requestBody->setExpectedAssessment(new ThreatExpectedAssessment('block'));
$requestBody->setCategory(new ThreatCategory('phishing'));
$result = $graphServiceClient->informationProtection()->threatAssessmentRequests()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.urlAssessmentRequest"
url = "http://test.com"
expectedAssessment = "block"
category = "phishing"
}
New-MgInformationProtectionThreatAssessmentRequest -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.url_assessment_request import UrlAssessmentRequest
from msgraph.generated.models.threat_expected_assessment import ThreatExpectedAssessment
from msgraph.generated.models.threat_category import ThreatCategory
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = UrlAssessmentRequest(
odata_type = "#microsoft.graph.urlAssessmentRequest",
url = "http://test.com",
expected_assessment = ThreatExpectedAssessment.Block,
category = ThreatCategory.Phishing,
)
result = await graph_client.information_protection.threat_assessment_requests.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#informationProtection/threatAssessmentRequests/$entity",
"@odata.type": "#microsoft.graph.urlAssessmentRequest",
"id": "8d87d2b2-ca4d-422c-f8df-08d774a5c9ac",
"createdDateTime": "2019-11-29T08:26:09.8196703Z",
"contentType": "url",
"expectedAssessment": "block",
"category": "phishing",
"status": "pending",
"requestSource": "administrator",
"url": "http://test.com",
"createdBy": {
"user": {
"id": "c52ce8db-3e4b-4181-93c4-7d6b6bffaf60",
"displayName": "Ronald Admin"
}
}
}