“When I use the Set Content Status Approval action to change the approval status to Approved, the Power Automate flow just hangs there with a Bad Gateway error on that action”
If you decide that the simple content approval in SharePoint is not enough, you can replace it with Power Automate flow. And in that flow you’ll use the ‘Set content approval status’ to update the status at the end. You probably won’t encounter any problems if a SharePoint library allows only major versions. But once you allow minor versions, the action can cause problems. The action might end with “BadGateway” and the whole flow will fail.
What’s the problem?
When setting the content approval status, it must go in a specific order. The document starts as ‘Draft’. Once it’s submitted for approval, it’ll go into ‘Pending’ status. From there it can be ‘Approved’ or ‘Rejected’. You can’t skip the order. If document is in ‘Draft’, you can’t approve nor reject it directly. It must be in the ‘Pending’ status before that.
That’s very often the problem. If you’re building your own approval flow, you must go through all the states. Don’t approve/reject directly, set the status ‘Pending’ with the ‘Submit’ action first.
Document update in the flow
It’s not only at the beginning of the flow to inform users, you should update the status after each update, e.g. when you update the approval information. If you enable content approval and minor versions, then each update will turn the document back to ‘Draft’. Even updates by Power Automate. And as already explained above, you can’t approve/reject document directly from ‘Draft’ status. The content approval process must always follow the same steps: Draft -> Pending -> Approved/Rejected. Translated to the ‘Set content approval status’ action: (create/update) -> Submit -> Approve/Reject.
Summary
If you use Power Automate flow to replace the standard content approval process, you must follow the status order. If document is in status ‘Draft’, you must ‘Submit’ it for content approval. Only documents in ‘Pending’ status can be approved or rejected. And the important point – each update in the flow will turn the document back into ‘Draft’. That means you must set it back to ‘Pending’ before the final approval/rejection.
When automating content approval for an item in a list, rather than a file in a library, how to get the eTag?
Hello Julie,
ETag is needed only for files. Items don’t have an ETag, keep the field empty.
Hi,
I am using a Sharepoint List (enabled content approval) and need to automatically trigger an approval for each submission.
Based on approval status, i want to ‘set the content approval status’ to Approved/Rejected but i am getting the Bad Gateway error. Can you please help?
Hello Brooke,
with SharePoint list items it should be very straightforward, I’d just check if:
Hi,
When a document is in the approval/reject status, I still need it to be available without the modifications? Can this be done by manually customising current flows? e.g. copy the document?
Hello Lydia,
I don’t understand what you’re trying to achieve. If the file is approved/rejected, it’s fully available. You just need to approve it again after each change.
Hi thanks for the article – its exactly what I’m seeing. in our environment.
Our flow has been forced back to Draft as someone edited the document while in the workflow (so change from pending to draft). Then we got the bad gateway and the 502 / 500 inner error when it went via the approval steps:
{
“error”: {
“code”: 502,
“source”: “uk-001.azure-apim.net”,
“clientRequestId”: “776fc4bc-e2d4-4f61-94ea-2186ae713461”,
“message”: “BadGateway”,
“innerError”: {
“status”: 500,
“message”: “The current state of the item is Draft and the following action Approve cannot be implemented\”\r\nclientRequestId: 776fc4bc-e2d4-4f61-94ea-2186ae713461\r\nserviceRequestId: 776fc4bc-e2d4-4f61-94ea-2186ae713461”
}
}
}
I’m sure its me but I dont quite see from your article how i would stop this happening but our flow is on sharepoint file approaval as follows:
When an item of file is modified (wait for pending using a trigger on the advanced config)
Get file metadata (gets the etag etc)
Start and wait for the approval
Condition (approved or not approved)
YES: Set content approval status (this is where we get the bad gateway
Do you know the best way to ensure the draft change effectively ends the approval flow? We can start again with a submission to change it to pending via the Sharepoint portal submit for approval button.
Thanks
Ian
Hello Ian,
you can’t stop it from happening, that’s standard SharePoint functionality. If there’s a need to approve content in a document library, every change in the document will move it back to ‘Draft’. The only thing you can do is to set it back to ‘Pending’ after each update and then ‘Approve/Reject’.
I perform a checkout in the beginning of the flow and check it back in at the end where i then immediately submit and then approve/reject. The document being checked out at the beginning sets it to draft so it is in the expected draft state when you reach the end steps.
Another benefit of checking it out is that you can update properties throughout the flow without going through the submit step each time. I update a separate column with the pending status so the end user knows what is going on while the checkout icon is present and regular column shows draft.
Thank you very much! I’ve been grappling with this for hours, and the update properties made all the difference!
Hi,
Is it possible to edit a document during document approval workflow in power automate. Content approval status and document versioning enabled document library.
Hello Sheefer,
if users have the required permissions then you can edit a document, just keep in mind that each edit will switch it back to draft in the same way the update by the flow will.
I’ve been running into a strange issue. I modified the approval process to look up the approver based on criteria in the library. I can set the content approval status to ‘Submit,’ which changes the status in SharePoint to ‘Pending.’ But then ‘Set content approval status – Approved,’ it uses the requestor’s user ID instead of the approvers and I don’t see any setting to change this. The approval status of course fails because the requestor doesn’t have approve permissions.