SOLVED

Post comment to a modern site page using REST api

Iron Contributor

Using this endpoint:

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

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? 
 
2 Replies
best response confirmed by matt howell (Iron Contributor)
Solution

@matt howell 

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.

@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?
1 best response

Accepted Solutions
best response confirmed by matt howell (Iron Contributor)
Solution

@matt howell 

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.

View solution in original post