cannot access specific team site using share-point rest apis

%3CLINGO-SUB%20id%3D%22lingo-sub-1106659%22%20slang%3D%22en-US%22%3Ecannot%20access%20specific%20team%20site%20using%20share-point%20rest%20apis%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1106659%22%20slang%3D%22en-US%22%3E%3CP%3Egoal%3A%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20create%20a%20folder%20in%20my%20custom%20team%20site%20in%20share-point%20using%20REST%20APIs.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eprior%20steps%20I%20have%20done%20before%20that%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3EI%20have%20register%20the%20my%20app%20in%20share-point%20using%20following%20URL.%3C%2FSTRONG%3E%20%3CEM%3E%3CA%20href%3D%22https%3A%2F%2Fccdevanoop.sharepoint.com%2Fsites%2FModernTeamSite%2F_layouts%2F15%2Fappregnew.aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2F***.sharepoint.com%2Fsites%2FModernTeamSite%2F_layouts%2F15%2Fappregnew.aspx%3C%2FA%3E%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20App%20%22permission%20request%20XML%22%20%2C%20I%20have%20provide%20below%20content.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3CAPPPERMISSIONREQUESTS%20allowapponlypolicy%3D%22true%22%3E%0A%20%20%3CAPPPERMISSIONREQUEST%20scope%3D%22http%3A%2F%2Fsharepoint%2Fcontent%2Fsitecollection%2Fweb%22%20right%3D%22FullControl%22%3E%3C%2FAPPPERMISSIONREQUEST%3E%0A%3C%2FAPPPERMISSIONREQUESTS%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Efor%20get%20Access%20Token%20for%20accessing%20those%20REST%20APIs%20I%20have%20also%20created%20a%20app%20in%20%22App%20Registration%22%20under%20Azure%20portal.%3C%2FP%3E%3CP%3Ewhen%20creating%20those%20I%20have%20provided%20following%20API%20permission%20for%20this%20app.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F165242i111A1D71BBDABC81%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22fdsaf.JPG%22%20title%3D%22fdsaf.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20doing%20so%20I%20was%20able%20to%20get%20the%20bearer%20access%20token.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F165243iA49658DEFFCD77EA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22token.JPG%22%20title%3D%22token.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThen%20I%20was%20able%20to%20create%20a%20folder%2C%20attache%20a%20file%20to%20a%20new%20app%20in%20share-point%20using%20rest%20apis.%3C%2FP%3E%3CP%3Ebut%20All%20those%20were%20happened%20in%20the%20%22Communication%20site%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20requirement%20is%20to%20create%20a%20folder%20inside%20a%20custom%20site%20(team%20site).%3C%2FP%3E%3CP%3Efor%20that%20I%20have%20created%20a%20custom%20site%20using%20web%20interface.%3C%2FP%3E%3CP%3EName%20called%3A%26nbsp%3B%3CSTRONG%3ETeamSite_ForB%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Efollowing%20is%20the%20REST%20endpoint%20url%20I'm%20trying%20to%20access%3A%3C%2FP%3E%3CP%3E%3CEM%3Ehttps%3A%2F%2F***.sharepoint.com%2Fsites%2FTeamSite_ForB%2F_api%2Fweb%2Ffolders%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20using%20postman%20in%20this%20case.%3C%2FP%3E%3CP%3Eso%2C%20in%20the%20authorization%20I%20have%20set%20the%20bearer%20token.%3C%2FP%3E%3CP%3Ein%20the%20request%20header%20section%20I%20set%20the%20followings.%3C%2FP%3E%3CTABLE%20border%3D%221%22%3E%3CTBODY%3E%3CTR%3E%3CTD%3Ekey%3C%2FTD%3E%3CTD%3Evalue%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3EContent-Type%3C%2FTD%3E%3CTD%3Eapplication%2Fjson%3Bodata%3Dverbose%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3EAccept%3C%2FTD%3E%3CTD%3E%3CSPAN%3Eapplication%2Fjson%3Bodata%3Dverbose%3C%2FSPAN%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3EX-RequestDigest%3C%2FTD%3E%3CTD%3E%3CSPAN%3E0x4AAF05C94B5EB91BF70B45A41166FADD431D5613120E4D2741B9DF8B383807331D1158CD236CDBE8A1DDBFC2162620CE0D6A62586CDBE45DD01745D777C7D66B%3C%2FSPAN%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%20the%20request%20body%20I%20have%20set%20the%20following%20json%20body.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%7B%20%0A%20%22__metadata%22%3A%7B%20%0A%20%20%22type%22%3A%22SP.Folder%22%0A%20%7D%2C%0A%20%22ServerRelativeUrl%22%3A%22%2Fsites%2FTeamSite_ForB%2FShared%20Documents%2FtestFolder%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ebut%20when%20I%20send%20the%20request%20I'm%20getting%20following%20error%20response%20with%20%22403%20forbidden%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%7B%0A%20%20%20%20%22error%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22code%22%3A%20%22-2147024891%2C%20System.UnauthorizedAccessException%22%2C%0A%20%20%20%20%20%20%20%20%22message%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22lang%22%3A%20%22en-US%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22value%22%3A%20%22Access%20denied.%20You%20do%20not%20have%20permission%20to%20perform%20this%20action%20or%20access%20this%20resource.%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E**Important**%3C%2FP%3E%3CP%3EIf%20I%20put%20url%20endpoint%20as%20below%20and%20request%20body%20as%20below%20I'm%20getting%20201%20response%20code%20and%20folder%20created%20inside%20%22communication%20site%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3Ehttps%3A%2F%2F***.sharepoint.com%2F_api%2Fweb%2Ffolders%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3Erequest%20body%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%7B%20%0A%20%22__metadata%22%3A%7B%20%0A%20%20%22type%22%3A%22SP.Folder%22%0A%20%7D%2C%0A%20%22ServerRelativeUrl%22%3A%22%2FShared%20Documents%2FtestFolder%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eso%2C%20I%20just%20don't%20want%20to%20create%20folder%20inside%20communication%20site%2C%20rather%20want%20to%20create%20inside%20custom%20team%20site.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20googled%20many%20articles%20and%20go%20through%20the%20share-point%20documentation%20and%20I%20couldn't%20find%20any%20solution%20for%20this%20error.%3C%2FP%3E%3CP%3Eplease%20can%20anyone%20give%20me%20insight%20what%20I'm%20doing%20wrong%20here.%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20highly%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

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.

fdsaf.JPG

 

After doing so I was able to get the bearer access token.

token.JPG

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.

keyvalue
Content-Typeapplication/json;odata=verbose
Acceptapplication/json;odata=verbose
X-RequestDigest0x4AAF05C94B5EB91BF70B45A41166FADD431D5613120E4D2741B9DF8B383807331D1158CD236CDBE8A1DDBFC2162620CE0D6A62586CDBE45DD01745D777C7D66B

 

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.

 

 

 

0 Replies