Update listItem
9/18/2020
2 minutes to read
In this article
Namespace: microsoft.graph
Update the properties on a listItem .
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)
Sites.ReadWrite.All
Delegated (personal Microsoft account)
Not supported.
Application
Sites.ReadWrite.All
HTTP request
Update the properties on a listItem.
PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}
Update column values on a listItem.
PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields
Name
Value
Description
if-match
etag
If this request header is included and the eTag provided does not match the current eTag on the item, a 412 Precondition Failed
response is returned and the item will not be updated.
Request body
In the request body, supply a JSON representation of a fieldValueSet specifying the fields to update.
Response
If successful, this method returns a 201 Created
response code and a fieldValueSet in the response body for the updated list item.
Example
The following example updates the Color and Quantity fields of the list item with new values. All other values on the listItem are left alone.
Request
PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields
Content-Type: application/json
{
"Color": "Fuchsia",
"Quantity": 934
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var fieldValueSet = new FieldValueSet
{
AdditionalData = new Dictionary<string, object>()
{
{"Color", "Fuchsia"},
{"Quantity", "934"}
}
};
await graphClient.Sites["{site-id}"].Lists["{list-id}"].Items["{item-id}"].Fields
.Request()
.UpdateAsync(fieldValueSet);
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 fieldValueSet = {
Color: "Fuchsia",
Quantity: 934
};
let res = await client.api('/sites/{site-id}/lists/{list-id}/items/{item-id}/fields')
.update(fieldValueSet);
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/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/sites/{site-id}/lists/{list-id}/items/{item-id}/fields"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphFieldValueSet *fieldValueSet = [[MSGraphFieldValueSet alloc] init];
[fieldValueSet setColor:@"Fuchsia"];
[fieldValueSet setQuantity: 934];
NSError *error;
NSData *fieldValueSetData = [fieldValueSet getSerializedDataWithError:&error];
[urlRequest setHTTPBody:fieldValueSetData];
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.
IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
FieldValueSet fieldValueSet = new FieldValueSet();
fieldValueSet.Color = "Fuchsia";
fieldValueSet.Quantity = 934;
graphClient.sites("{site-id}").lists("{list-id}").items("{item-id}").fields()
.buildRequest()
.patch(fieldValueSet);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
Response
HTTP/1.1 201 Created
Content-type: application/json
{
"Name": "Widget",
"Color": "Fuchsia",
"Quantity": 934
}