I want to update certain fields for a ListItem in Sharepoint. How can I achieve this via the REST API?
Is there any documentation for this?
EDIT 1
Consider the following JSON that I receive on requesting a ListItem(GET)
{
"d": {
"__metadata": {
"id": "8b3d2196-ad3e-4766-a23e-7e6a89153965",
"uri": "https://abc-my.sharepoint.com/personal/nn_abc_co/_api/Web/Lists(guid'd02a8c5b-cd69-4aa8-b7fb-9d539733f285')/Items(383)",
"etag": "\"2\"",
"type": "SP.Data.DocumentsItem"
},
"FirstUniqueAncestorSecurableObject": {
"__deferred": {
"uri": ".../FirstUniqueAncestorSecurableObject"
}
},
"RoleAssignments": {
"__deferred": {
"uri": ".../RoleAssignments"
}
},
"AttachmentFiles": {
"__deferred": {
"uri": ".../AttachmentFiles"
}
},
"ContentType": {
"__deferred": {
"uri": ".../ContentType"
}
},
"FieldValuesAsHtml": {
"__deferred": {
"uri": ".../FieldValuesAsHtml"
}
},
"FieldValuesAsText": {
"__metadata": {
"id": ".../FieldValuesAsText",
"uri": ".../_api/Web/Lists(guid'd02a8c5b-cd69-4aa8-b7fb-9d539733f285')/Items(383)/FieldValuesAsText",
"type": "SP.FieldStringValues"
},
"ContentTypeId": "0x0120000E7EB3018A9074468823208C432BDCA5",
"Title": "",
"IsMyDocuments": "",
"SharedWithInternal": "",
"SharedWithUsers": "",
"ID": "383",
"Created": "7/29/2014 11:28 PM",
"Author": "3",
"Modified": "7/29/2014 11:28 PM",
"Editor": "3",
"OData__x005f_CopySource": "",
"CheckoutUser": "",
"OData__x005f_UIVersionString": "1.0",
"GUID": "da1e223b-1335-49e8-a544-b2cbebd4064f",
"OData__x005f_ModerationStatus": "Approved",
"OData__x005f_Level": "1",
"UniqueId": "3dba6291-92c7-458f-9a28-e0a91696d9ca",
"FSObjType": "1",
...
},
"FileSystemObjectType": 1,
"Id": 383,
"ContentTypeId": "0x0120000E7EB3018A9074468823208C432BDCA5",
"Title": null,
"IsMyDocuments": null,
"SharedWithInternalId": null,
"SharedWithUsersId": {
"__metadata": {
"type": "Collection(Edm.Int32)"
},
"results": [5]
},
... }
}
From the JSON above(which I have altered ofcourse, but is a real response), I need to change the value for "SharedWithUsers" under "FieldValuesAsText" object.
Is this possible? I have been trying it, and even the call returns success response code, but it doesn't change anything.
On the other hand if I change fields in the first level, by that I mean fields like "Title", it changes successfully.
However(beyond my understanding) values like "SharedWithUsersId" in the first level don't change either. Even though I get the same success response code for it as well.
The Post data I am creating is as follows,
For Title (works like a charm! Every blog that I have read, refers this example!)
{
"__metadata": {
"type": "SP.Data.DocumentsItem"
},
"Title":"Blabla"
}
For SharedWithUsers field under FieldValuesForEdit OR FieldValuesAsText
{
"__metadata": {
"type": "SP.Data.DocumentsItem"
},
"FieldValuesForEdit": {
"__metadata": {
"type": "SP.FieldStringValues"
},
"SharedWithUsers": ""
}
}
I have verified that SharedWithUsers's value is "" when it doesn't contain any data (the sample JSON i have posted confirms it) But POST call with such data doesn't update it.
For SharedWithUsersId
{
"__metadata": {
"type": "SP.Data.DocumentsItem"
},
"SharedWithUsersId": {
"__metadata": {
"type": "Collection(Edm.Int32)"
},
"results": []
}
}
Note here that in this case >>> "SharedWithUsersId":null doesn't work either, even though my own sinful eyes have seen such a response for some items! (All Hail Microsoft!!!)
For all of the above POST data JSON objects, I get a 204 response code (which I believe is the right code for a MERGE call)
I hope I have explained my question well enough. Any or all help is appreciated!