Forum Discussion

Ova Incekaraoglu's avatar
Ova Incekaraoglu
Copper Contributor
Jun 28, 2018

UnauthorizedAccessException error when using REST Call in Workflow

I am trying to get a user's line manager in a workflow in a SharePoint online site collection.

I have followed the exact steps https://www.credera.com/blog/technology-insights/microsoft-solutions/sharepoint-2013-online-accessing-user-profile-properties-in-a-designer-workflow/ and and also running with App Step -elevated permissions- as you can see in screenshot. I have already gave trust to Workflow on appinv.aspx following the steps https://docs.microsoft.com/en-us/sharepoint/dev/general-development/create-a-workflow-with-elevated-permissions-by-using-the-sharepoint-workflo.

 

Rest call URL is something like this:https://mycompanyname.sharepoint.com/sites/forms/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='Manager')?@v=%27i:0%23.f%7Cmembership%7CMYACCOUNT%27

With this URL I CAN access the response from browser, and get the line manager.

However in the workflow, no matter what I did it's erroring.

 

  {"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."}}} 

I logged the 'Dictionary'(Headers) and it looks like it's adding an extra / in there:

**{"Accept":"application\/json;odata=verbose","Content-Type":"application\/json;odata=verbose"}**

Result

this dictionary is looking like this in Workflow.

 

I really don't understand why the Rest call is working in browser, and not working inside the workflow. As I said I have already given FullControl to Workflow app in appinv.aspx.

I am also unable to understand why it adds the extra "\" into the Request Header (Headers/ dictionary)

Please help! If GetUserProfilePropertyFor cannot be called like this, let me know so this torture ends.

1 Reply

  • Robert Bisom's avatar
    Robert Bisom
    Copper Contributor

    Hello Ova,

    we are solving all the same issue. Did you solved it?

    Thank you.

    Rob