Workflow error in SP2013 related to App Step

I had a situation when my workflows went to “Suspended” after a few minutes. I noticed this occured when I used the “App Step”. Looking at the “Suspended” state, there was an “i” icon, when clicked, showed this error:
Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.ApplicationException: HTTP 401 {“error_description”:”The server was unable to process the request due to an internal error

Here is how the error actually consistently appears:
WF Suspended

It turns out the App Step will not work, without specific configuration to grant the App Step rights.

So of course some permission issue was most probable. And I was suspicious of App Step, as I mentioned yesterday as the proximate cause.

So configured the permission as below link:
https://www.dmcinfo.com/latest-thinking/blog/id/8661/create-site-from-template-using-sharepoint-2013-workflow

The description in the above link should make things really clear. So when an App Step runs, it uses permissions that needed to be set.

One more thing, we need specify the Scope URL as below

On the subweb, you will find the configuration setting for app permission: http :[SPWeb URL] /_layouts/15/appinv.aspx

You can see it set up from here:
[site URL] /_layouts/15/appprincipals.aspx?Scope=Web

Here is the feature to enable:
WFAppStepFeatureToEnable

For App Step Permissions, it is the 3rd link under permissions from Site Settings.

Here is how the specific App Step Permission appears when viewed from Site Settinga App Step Permissions:
SpecificAppStepPermissionDefinition

With the permissions granted, the workflows should then work on retry. You can retry from the workflow summary page shown on top

Errors trying to publish SP2013 workflows

Recently I encountered an issue trying to publish SP2013 workflows.  Every attempt to save the workflow gave an odd error about the underlying XML. I traced into the ULS log which showed: “Cannot set unknown member ‘LookupSPListItemDoubleProperty.ItemId”.

The problem was related to the binding between the Workflow Manager instance and the IIS Site that supports the SharePoint web application. The key was to rebind them.  Here’s the command to do so:

Register-SPWorkflowService –SPSite "http://yoursite" -WorkflowHostUri “http://localhost:12291” -AllowOAuthHttp -Force

If that doesn’t do the trick, let’s restart by running the Workflow Configuration Wizard, to rejoin the SharePoint farm to the workflow farm. Note you need to know:
– Service account password
– Database instance
– Workflow passphrase

Once that is done be sure to check IIS bindings for the workflow manager site. Both 12290 and 12291 should be configured.

Then issue the first CmdLet above for registering the SPWorkflow Service.

Voila!