Friday, March 16, 2018

Microsoft Flow | Get Access Denied for REST API SharePoint call

Scenario: Using Microsoft Flow you need to call HTTP Rest API methods and for that it needs Access Token authorization. You get "Access Denied" permissions error.

Error:
"Access denied. You do not have permission to perform this action or access this resource"

To Get Access Token for Authorization
There are many articles online regarding this topic and mostly viewed are below one, from where I got most of the knowledge too.

http://sharepointscribblings.blogspot.cz/2017/07/call-any-sharepoint-rest-api-from.html

http://www.ktskumar.com/2017/01/access-sharepoint-online-using-postman/

However, while creating my own Flow and trying to get access tokens, I have faced some issues even after following above 2 articles. one of them I have created an article on "Invalid Client Secret" key error.

Another issue I encountered was when working for subsites or O365 group sites. It would just give me "Access denied" permissions in response body even in POSTMAN. it would not work. Below is what I had to do to fix that.

Even if you are Site Collection Administrator, you will get this issue. Even if you have Trusted the APP with below code, you will get the "Access Denied" error.


   


After spending many hours and almost giving up, I modified the Trust App code to below and Wow! It worked. It worked for a Subsite and for O365 group site.


     
   


So, it is chance you can either use the first code or the second code while Trusting the APP. you cannot use both. Either of one should work. You do not need to create a new Trusted APP. for an existing APP also you can re-trust it with other 'AppPermissionRequest' tag and it will take the new one that you enter.

For more details on SharePoint App Permission Scope, please read this Microsoft Article

5 comments:

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi,

I'm having the same issue and even following the mentioned steps I still receive access denied.

I'm using SharePoint - Create File action.

Do you have other Idea about what can I do?

Unknown said...

cant see code or image. Would like to know as im having this issue at the moment but cant figure it out.

chanti said...

I have the exact same isssue,can you please post the code so I can try it out. The code part is blank in your post

chanti said...

Never mind found it, use Scope URI - http://sharepoint/content/sitecollection

Total Pageviews