0

I am trying to utilize REST api to get/set discussion list fields. I am facing issue for following fields,

I am able to set below fields using CSOM but I want to set it using REST api because I am planning to utilize outside of SharePoint.

Best Reply: BestAnswerId

Mark as Featured: IsFeatured

Enterprise keywords/tags

Update: below is my data. when I call api using below data, Title gets updated but not BestAnwserId.

var itemProperties = {
    '__metadata': { "type": "SP.Data.Community_x0020_DiscussionListItem" },
    'BestAnswerId':64,
    'Title':"updatedd"      
       
    };

2 Answers 2

0

The BestAnswerId and the IsFeatured are properties on the original post, so a GET request on the original post itself will show true/false if that post was featured, same with BestAnswerId by showing the item ID that was marked as best reply.

You can view the result with a request such as:

https://yourtenantname.sharepoint.com/sites/yoursite/_api/web/lists/getbytitle('discussionboard')/items/getbyid(1)

Where 1 is the ID for the original post.

Note, for the enterprise keywords, you will need to enable it on the list itself first, so the column gets created. After it will be available through the TaxKeyword field.

1
  • Yes I can get BestAnswerId and IsFeatured fields but while setting it doest work. for other fields it works.
    – Anil Pal
    Commented Jun 11, 2020 at 10:11
0

All the property for fields in Rest API can be got from Item endpoint:

/_api/web/lists/getbytitle('ListName')/items

enter image description here

6
  • Yes I can get BestAnswerId and IsFeatured fields but while setting it doest work. for other fields it works
    – Anil Pal
    Commented Jun 11, 2020 at 10:12
  • @AnilPal, the BestAnswerId should be int value rather than a string value, please set like this: 'BestAnswerId': 64
    – Jerry
    Commented Jun 15, 2020 at 8:17
  • tried passing int value but still doesn't work. I don't know why this is happening while same way CSOM works.
    – Anil Pal
    Commented Jun 17, 2020 at 11:52
  • Seems this is because "ReadOnlyField" property for BestAnswerId column is set to true, please check with this endpoint: /_api/web/lists/getbyTitle('ListName')/fields/getbyTitle('Best Response Id'), this property can't be updated via Rest I have tested like this : codesharepoint.com/rest-api/… I think this is causing the issue. But csom code is working actually.
    – Jerry
    Commented Jun 19, 2020 at 7:14
  • I guess, "ReadOnlyField" cannot not be true. Otherwise CSOM code will also not work. May be It is not exposed in REST API. what you say?
    – Anil Pal
    Commented Jun 19, 2020 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.