Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Create a new workbookComment object.
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) |
Files.ReadWrite |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Not supported. |
Not supported. |
HTTP request
POST /me/drive/items/{id}/workbook/comments
POST /me/drive/root:/{item-path}:/workbook/comments
POST /users/{id}/drive/items/{id}/workbook/comments
POST /users/{id}/drive/root:/{id}:/workbook/comments
Request body
In the request body, supply a JSON representation of a workbookComment object.
Response
If successful, this method returns a 201 Created
response code and a new workbookComment object in the response body.
Examples
The following example shows how to create a comment of a plain
contentType.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/me/drive/items/01CYZLFJGUJ7JHBSZDFZFL25KSZGQTVAUN/workbook/comments
Content-Type: application/json
{
"cellAddress": "Sheet1!A1",
"content": "This is my comment.",
"contentType": "plain"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new WorkbookComment
{
Content = "This is my comment.",
ContentType = "plain",
AdditionalData = new Dictionary<string, object>
{
{
"cellAddress" , "Sheet1!A1"
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Workbook.Comments.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.NewWorkbookComment()
content := "This is my comment."
requestBody.SetContent(&content)
contentType := "plain"
requestBody.SetContentType(&contentType)
additionalData := map[string]interface{}{
"cellAddress" : "Sheet1!A1",
}
requestBody.SetAdditionalData(additionalData)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
comments, err := graphClient.Drives().ByDriveId("drive-id").Items().ByDriveItemId("driveItem-id").Workbook().Comments().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
WorkbookComment workbookComment = new WorkbookComment();
workbookComment.setContent("This is my comment.");
workbookComment.setContentType("plain");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("cellAddress", "Sheet1!A1");
workbookComment.setAdditionalData(additionalData);
WorkbookComment result = graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").workbook().comments().post(workbookComment);
const options = {
authProvider,
};
const client = Client.init(options);
const workbookComment = {
cellAddress: 'Sheet1!A1',
content: 'This is my comment.',
contentType: 'plain'
};
await client.api('/me/drive/items/01CYZLFJGUJ7JHBSZDFZFL25KSZGQTVAUN/workbook/comments')
.version('beta')
.post(workbookComment);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\WorkbookComment;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new WorkbookComment();
$requestBody->setContent('This is my comment.');
$requestBody->setContentType('plain');
$additionalData = [
'cellAddress' => 'Sheet1!A1',
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->workbook()->comments()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.workbook_comment import WorkbookComment
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = WorkbookComment(
content = "This is my comment.",
content_type = "plain",
additional_data = {
"cell_address" : "Sheet1!A1",
}
)
result = await graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').workbook.comments.post(request_body)
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
{
"content": "This is my comment.",
"contentType": "plain",
"id": "{97A21473-8339-4BF0-BCB6-F55E4909FFB8}",
"cellAddress": "Sheet1!A1",
"richContent": "",
"mentions": []
}
The following example shows how to create a comment of a mention
contentType.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/me/drive/items/01CYZLFJGUJ7JHBSZDFZFL25KSZGQTVAUN/workbook/comments
Content-Type: application/json
{
"cellAddress": "Sheet1!A1",
"richContent": "<at id=\"0\">Kate Kristensen</at> - This is my comment.",
"mentions": [
{
"id": 0,
"name": "Kate Kristensen",
"email": "kakri@contoso.com"
}
],
"contentType": "mention"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
using Microsoft.Kiota.Abstractions.Serialization;
var requestBody = new WorkbookComment
{
ContentType = "mention",
AdditionalData = new Dictionary<string, object>
{
{
"cellAddress" , "Sheet1!A1"
},
{
"richContent" , "<at id=\"0\">Kate Kristensen</at> - This is my comment."
},
{
"mentions" , new List<object>
{
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"id", new UntypedString("0")
},
{
"name", new UntypedString("Kate Kristensen")
},
{
"email", new UntypedString("kakri@contoso.com")
},
}),
}
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Workbook.Comments.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
WorkbookComment workbookComment = new WorkbookComment();
workbookComment.setContentType("mention");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("cellAddress", "Sheet1!A1");
additionalData.put("richContent", "<at id=\"0\">Kate Kristensen</at> - This is my comment.");
LinkedList<Object> mentions = new LinkedList<Object>();
property = new ();
property.setId(0);
property.setName("Kate Kristensen");
property.setEmail("kakri@contoso.com");
mentions.add(property);
additionalData.put("mentions", mentions);
workbookComment.setAdditionalData(additionalData);
WorkbookComment result = graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").workbook().comments().post(workbookComment);
const options = {
authProvider,
};
const client = Client.init(options);
const workbookComment = {
cellAddress: 'Sheet1!A1',
richContent: '<at id=\"0\">Kate Kristensen</at> - This is my comment.',
mentions: [
{
id: 0,
name: 'Kate Kristensen',
email: 'kakri@contoso.com'
}
],
contentType: 'mention'
};
await client.api('/me/drive/items/01CYZLFJGUJ7JHBSZDFZFL25KSZGQTVAUN/workbook/comments')
.version('beta')
.post(workbookComment);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\WorkbookComment;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new WorkbookComment();
$requestBody->setContentType('mention');
$additionalData = [
'cellAddress' => 'Sheet1!A1',
'richContent' => '<at id=\"0\">Kate Kristensen</at> - This is my comment.',
'mentions' => [
[
'id' => 0,
'name' => 'Kate Kristensen',
'email' => 'kakri@contoso.com',
],
],
];
$requestBody->setAdditionalData($additionalData);
$result = $graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->workbook()->comments()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.workbook_comment import WorkbookComment
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = WorkbookComment(
content_type = "mention",
additional_data = {
"cell_address" : "Sheet1!A1",
"rich_content" : "<at id=\"0\">Kate Kristensen</at> - This is my comment.",
"mentions" : [
{
"id" : 0,
"name" : "Kate Kristensen",
"email" : "kakri@contoso.com",
},
],
}
)
result = await graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').workbook.comments.post(request_body)
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
{
"content": "@Kate Kristensen - This is my comment.",
"contentType": "mention",
"id": "{97A21473-8339-4BF0-BCB6-F55E4909FFB8}",
"richContent": "<at id=\"0\">Kate Kristensen</at> - This is my comment.",
"mentions": [
{
"id": 0,
"name": "Kate Kristensen",
"email": "kakri@contoso.com"
}
],
"cellAddress": "Sheet1!A1"
}