SOLVED

Uploading files via SPO REST API failing when having a workflow on the library

%3CLINGO-SUB%20id%3D%22lingo-sub-45922%22%20slang%3D%22en-US%22%3EUploading%20files%20via%20SPO%20REST%20API%20failing%20when%20having%20a%20workflow%20on%20the%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45922%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20using%20the%20SPO%20REST%20API%20to%20PUT%20files%20into%20SPO%20document%20library.%20We%20are%20also%20doing%20a%20PATCH%20to%20update%20content%20and%20metadata.%20On%20the%20document%20library%20we%20have%20a%20SP%20Designer%20workflow%20that%20starts%20when%20item%20is%20changed.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20seems%20that%20the%20workflow%20is%20interfering%20with%20the%20PATCH%20as%20we%20are%20seeing%20occacional%20%22microsoft.sharepoint.spexception%3A%20the%20file%20has%20been%20modified%20by%22%20errors%20manifesting%20itself%20as%20a%20409.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETurning%20of%20the%20workflow%20resolves%20the%20issue%2C%20but%20that%20is%20not%20an%20option.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHas%20anyone%20experienced%20something%20like%20this%2C%20and%20maybe%20have%20a%20solution%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47348%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20files%20via%20SPO%20REST%20API%20failing%20when%20having%20a%20workflow%20on%20the%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47348%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20a%20bunch!%20That%20seemed%20to%20be%20it.%20I%20will%20test%20some%20more%20and%20give%20and%20update%20later.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47284%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20files%20via%20SPO%20REST%20API%20failing%20when%20having%20a%20workflow%20on%20the%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47284%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20challenge%20is%20as%20soon%20as%20one%20column%20update%20happens%2C%20the%20workflow%20is%20triggered%20while%20you%20are%20still%20updating%20other%20content%20on%20the%20record.%20There%20is%20no%20lock%20put%20on%20the%20record%20to%20prevent%20it%20from%20firing.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20to%20turn%20off%20the%20item%20update%20event%20triggering%20for%20the%20list%20and%20see%20if%20that%20prevents%20the%20workflow%20from%20firing.%20Here%20is%20link%20to%20an%20article%20that%20might%20help%20-%20%3CA%20href%3D%22http%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F94362%2Ftemporarily-disable-workflow-on-single-list-item%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F94362%2Ftemporarily-disable-workflow-on-single-list-item%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20are%20other%20challenges%20with%20batch%20updates%20but%20if%20it%20works%20for%20one%20record%2C%20then%20then%20could%20plan%20for%20batches.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47275%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20files%20via%20SPO%20REST%20API%20failing%20when%20having%20a%20workflow%20on%20the%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47275%22%20slang%3D%22en-US%22%3EIs%20it%20possible%20that%20the%20workflow%20is%20'updating'%20the%20item%20in%20the%20form%20of%20updating%20the%20workflow%20status%20column%3F%3CBR%20%2F%3E%3CBR%20%2F%3ETry%20configure%20the%20workflow%20and%20not%20set%20the%20workflow%20status%20in%20the%20column%2C%20this%20means%20when%20workflow%20starts%20it%20doesn't%20modify%20the%20list%20item.%3CBR%20%2F%3E%3CBR%20%2F%3EThen%20it%20shouldn't%20cause%20problems%20for%20the%20Patch%20op.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-46087%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20files%20via%20SPO%20REST%20API%20failing%20when%20having%20a%20workflow%20on%20the%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-46087%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20actually%20tried%20this.%20I%20added%20a%205%20minute%20%22Pause%22%20at%20the%20start%20of%20the%20workflow.%20This%20did%20not%20help.%20The%20thing%20is%20that%20the%20workflow%20doesn't%20actually%20do%20anything%20with%20the%20list%20item.%20It%20checks%20to%20see%20if%20certain%20metadata%20is%20set%20and%20on%20the%20time%20of%20the%20PUT%20and%20PATCH%20these%20metadata%20is%20not%20set%20so%20the%20workflow%20ends%20staight%20away.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20are%20using%20FilesConnect%20in%20Salesforce%20to%20move%20files%20in%20SharePoint.%20I%20fwe%20turn%20off%20the%20workflow%20everything%20works%20fine!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-45956%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20files%20via%20SPO%20REST%20API%20failing%20when%20having%20a%20workflow%20on%20the%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-45956%22%20slang%3D%22en-US%22%3Emaybe%20add%20a%20Pause%20(1%20to%205%20minutes)%20at%20the%20beginning%20of%20your%20workflow%2C%20give%20the%20PATCH%20time%20to%20settle%20in.%20Or%20you%20could%20set%20a%20%22Wait%20until%20field%20is%22%20action%20and%20have%20a%20boolean%20%22Ready%20to%20update%22%20field%2C%20that%20gets%20set%20to%20TRUE%20when%20your%20PATCH%20completes.%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi,

 

We are using the SPO REST API to PUT files into SPO document library. We are also doing a PATCH to update content and metadata. On the document library we have a SP Designer workflow that starts when item is changed.

 

It seems that the workflow is interfering with the PATCH as we are seeing occacional "microsoft.sharepoint.spexception: the file has been modified by" errors manifesting itself as a 409.

 

Turning of the workflow resolves the issue, but that is not an option.

 

Has anyone experienced something like this, and maybe have a solution?

5 Replies
Highlighted
maybe add a Pause (1 to 5 minutes) at the beginning of your workflow, give the PATCH time to settle in. Or you could set a "Wait until field is" action and have a boolean "Ready to update" field, that gets set to TRUE when your PATCH completes.
Highlighted

I have actually tried this. I added a 5 minute "Pause" at the start of the workflow. This did not help. The thing is that the workflow doesn't actually do anything with the list item. It checks to see if certain metadata is set and on the time of the PUT and PATCH these metadata is not set so the workflow ends staight away.

 

We are using FilesConnect in Salesforce to move files in SharePoint. I fwe turn off the workflow everything works fine!

Highlighted
Best Response confirmed by Pål Eilertsen (Occasional Contributor)
Solution
Is it possible that the workflow is 'updating' the item in the form of updating the workflow status column?

Try configure the workflow and not set the workflow status in the column, this means when workflow starts it doesn't modify the list item.

Then it shouldn't cause problems for the Patch op.
Highlighted

The challenge is as soon as one column update happens, the workflow is triggered while you are still updating other content on the record. There is no lock put on the record to prevent it from firing.

 

Try to turn off the item update event triggering for the list and see if that prevents the workflow from firing. Here is link to an article that might help - http://sharepoint.stackexchange.com/questions/94362/temporarily-disable-workflow-on-single-list-item

 

There are other challenges with batch updates but if it works for one record, then then could plan for batches.

 

 

Highlighted

Thanks a bunch! That seemed to be it. I will test some more and give and update later.