Skip to content

Instantly share code, notes, and snippets.

@vgrem
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgrem/69c8e8e6deee7cd63366 to your computer and use it in GitHub Desktop.
Save vgrem/69c8e8e6deee7cd63366 to your computer and use it in GitHub Desktop.
Example: update List Item
using (var client = new SPHttpClient(webUri, userName, password))
{
var listTitle = "Tasks";
var itemId = 1;
var itemPayload = new { __metadata = new { type = "SP.Data.TasksListItem" }, Title = "Approval Task"};
var endpointUrl = string.Format("{0}/_api/web/lists/getbytitle('{1}')/items({2})",webUri,listTitle,itemId);
var headers = new Dictionary<string,string>();
headers["IF-MATCH"] = "*";
headers["X-HTTP-Method"] = "MERGE";
client.ExecuteJson(endpointUrl,HttpMethod.Post,headers, itemPayload);
Console.WriteLine("Task item has been updated");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment