Sharepoint Server 2013 REST API returns 401 by calling 'FieldValuesAsHtml' in anonymous access
-
05-02-2021 - |
Question
I've followed the steps from the following answer: sharepoint 2013 anonymous 401 UNAUTHORIZED1
However, it works partially for me. The REST calls works when I try to access basic information from any list, but when I call 'FieldsValuesAsHtml' endpoint, the response is 401 Unauthorized.
Solution 2
Finally, I was able to solve the problem. In order to 'FieldValuesAsHtml' endpoints get to work with both Anonymous and registered users, you have to make the request with POST
method and empty body passing the header X-RequestDigest
and it's value.
I was able to get the header value from this endpoint: /_api/contextinfo
. Just be sure to call this before every 'FieldValuesAsHtml' requests.
OTHER TIPS
Check whether the following REST API works or not.
/_api/web/lists/getbytitle('listname')/items(28)
And then check the REST API below.
/_api/web/lists/getbytitle('listname')/items(28)?$expand=FieldValuesAsHtml