I am starting workflow on a list item using the server side code. It is getting started and immediately it is going to suspended state with 401: unauthorized exception. If I go the list with the same user credentials and terminate that instance and start the workflow it is getting run without issues. Below is the code and it is running with Run with elevated previleges.
var wfsrvmng = new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager(web);
var wfsubsrv = wfsrvmng.GetWorkflowSubscriptionService();
var wfsub = wfsubsrv.GetSubscription(new Guid(hdnWorkflowID.Value));
var wfi = wfsrvmng.GetWorkflowInstanceService();
Guid instanceID = wfi.StartWorkflowOnListItem(wfsub, lsItmRequest.ID, new Dictionary<string, object>());