Forum Discussion
buddhika_jayakodi
Jan 14, 2020Copper Contributor
cannot access specific team site using share-point rest apis
goal:
I want to create a folder in my custom team site in share-point using REST APIs.
prior steps I have done before that:
I have register the my app in share-point using following URL. https://***.sharepoint.com/sites/ModernTeamSite/_layouts/15/appregnew.aspx
In my App "permission request XML" , I have provide below content.
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl"/>
</AppPermissionRequests>
for get Access Token for accessing those REST APIs I have also created a app in "App Registration" under Azure portal.
when creating those I have provided following API permission for this app.
After doing so I was able to get the bearer access token.
Then I was able to create a folder, attache a file to a new app in share-point using rest apis.
but All those were happened in the "Communication site".
My requirement is to create a folder inside a custom site (team site).
for that I have created a custom site using web interface.
Name called: TeamSite_ForB
following is the REST endpoint url I'm trying to access:
https://***.sharepoint.com/sites/TeamSite_ForB/_api/web/folders
I'm using postman in this case.
so, in the authorization I have set the bearer token.
in the request header section I set the followings.
key | value |
Content-Type | application/json;odata=verbose |
Accept | application/json;odata=verbose |
X-RequestDigest | 0x4AAF05C94B5EB91BF70B45A41166FADD431D5613120E4D2741B9DF8B383807331D1158CD236CDBE8A1DDBFC2162620CE0D6A62586CDBE45DD01745D777C7D66B |
in the request body I have set the following json body.
{
"__metadata":{
"type":"SP.Folder"
},
"ServerRelativeUrl":"/sites/TeamSite_ForB/Shared Documents/testFolder"
}
but when I send the request I'm getting following error response with "403 forbidden"
{
"error": {
"code": "-2147024891, System.UnauthorizedAccessException",
"message": {
"lang": "en-US",
"value": "Access denied. You do not have permission to perform this action or access this resource."
}
}
}
**Important**
If I put url endpoint as below and request body as below I'm getting 201 response code and folder created inside "communication site".
https://***.sharepoint.com/_api/web/folders
request body
{
"__metadata":{
"type":"SP.Folder"
},
"ServerRelativeUrl":"/Shared Documents/testFolder"
}
so, I just don't want to create folder inside communication site, rather want to create inside custom team site.
I googled many articles and go through the share-point documentation and I couldn't find any solution for this error.
please can anyone give me insight what I'm doing wrong here.
Any help would be highly appreciated.
No RepliesBe the first to reply