Friday, July 28, 2017

How add value to User field using REST API

As all we know, SharePoint is having People field in list. We can add data for this field from custom webpart. There is lots of way to add listitems like server side (c#), client side (SP Client Context or REST API). We will see how to add value to user field using REST.

In REST, you can't get Proper column name of User Field. For Example, If you are having field with Owner as Column name. REST will not provide the value with Owner column. It will give two properities like OwnerId, OwnerString.

We have to pass the value for OwnerId. So first get the UserID for selected user. Then pass the ID to OwnerId field.


 let Listdata = JSON.stringify({
            "__metadata": { 'type': 'SP.Data.ListItem' },
           
    "OwnerId": 26
        })


No comments:

Post a Comment