Forum Discussion

mattchowell's avatar
mattchowell
Iron Contributor
Jun 14, 2021

Post comment to a modern site page using REST api

Using this endpoint:

https://xxx.sharepoint.com/sites/xxx/_api/web/Lists/GetByTitle('SitePages')/GetItemById(305)/Comments

And this listitementitytypefullname:

SP.Data.SitePagesItem
Response:
The property '__metadata' does not exist on type 'Microsoft.SharePoint.Comments.comment'. Make sure to only use property names that are defined by the type.
Where is it getting the "type" from? Shouldn't it be using the listitementitytypefullname? And if that's the wrong type, reflect that in the error? And if wrong, what should the listitementitytypefullname: be for site page comments? 
 
  • mattchowell 

    You need to use Microsoft.SharePoint.Comments.comment as listitementitytypefullname instead of SP.Data.SitePagesItem.


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

  • mattchowell 

    You need to use Microsoft.SharePoint.Comments.comment as listitementitytypefullname instead of SP.Data.SitePagesItem.


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    • mattchowell's avatar
      mattchowell
      Iron Contributor
      ganeshsanap Thanks - I did initially try with Microsoft.SharePoint.Comments.comment and it failed probably due to some other issue, but now it works. Do you know if it's possible to reflect a user's name instead of the app name as the author, and if so how?

Resources