Sometimes your SharePoint workflow refuses to start. Like the time I tried to programmatically start a SharePoint 2013 workflow within a timer job. When the timer job ran, the workflow attempted to start but ended in a Canceled state. When clicking the information icon from the Workflow Information page, I got the following (partial) error message:
Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.ApplicationException: HTTP 401 {“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 found a lot of posts suggesting that the user kicking off the workflow needs to be in a certain SharePoint group, or the app pool user needs certain permissions, etc.
However, what finally solved my issue was enabling the Workflows can use app permissions feature from the Manage Site Features page. This forum post is what pointed me in the right direction.
I hope this helps somebody else out there!
Was this a custom workflow? Did you just turn the feature on, or turn it on then do something to the workflow so it knows to use app permissions?
I found that my issue was that the person who uploaded the workflow, if their permission ever got revoked from the site, the workflow would get that error message.
Hi Paul, it was a SharePoint Designer 2013 workflow that I was trying to fire from code. All I did was turn on the feature, nothing else. I found a lot of stuff on permissions, seems like that is a common issue as well, but that didn’t turn out to be the cause of my issue.