Today I tried to import a solution with a few flows in a solution.
The error
Table of Contents
After I imported the solution and then tried to turn on the flow, I was presented with the following error:
Flow client error returned with status code “BadRequest” and details “{“error”:{“code”:”InvalidOpenApiFlow”,”message”:”Flow save failed with code ‘MultipleErrorsOccurred’ and message ‘The dynamic operation request to API ‘sharepointonline’ operation ‘GetTable’ failed with status code ‘Unauthorized’. This may indicate invalid input parameters. Error response: {\r\n “error_description”: “Exception of type ‘Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException’ was thrown.”\r\n};The dynamic operation request to API ‘sharepointonline’ operation ‘GetTable’ failed with status code ‘Unauthorized’. This may indicate invalid input parameters. Error response: {\r\n “error_description”: “Exception of type ‘Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException’ was thrown.”\r\n}’.”}}”.

I’ve come across this problem a few times recently, so it is time to write a blog post on this.
Turn on a flow
To Turn on a flow should all be simple. You import a solution and then you select Turn on.
But often this goes wrong. Not because your flow is broken, but because of other reasons.
The dynamic operation request to API ‘sharepointonline’ operation ‘GetTable’ failed with status code ‘Unauthorized’
The The dynamic operation request to API ‘sharepointonline’ operation ‘GetTable’ failed with status code ‘Unauthorized’ error message does give us a bit of a clue, although it is not obvious.
Also, that this error message has only stared to happen in recent months is also a clue.
Since I’ve started using the Environment variables to set connections within my flows, I’ve every now and then got these errors complaining about not being able to access SharePoint tables/lists when activating a flow.
The reason why this error may be shown is simple.
Review all the environment variable values and set the values correctly. Once they have been updated and set correctly the flows will enable.
Typically when you develop a solution in one tenant and then import it into a different tenant you will have to update urls within the SharePoint site environment variables.
Why does this happen?
If you activate your flow before you have updated all the environment variables. The flow will validate the connections to the tenant where the solution was developed. Obviously with the logins used during the import you don’t have access to those sites.
Other reasons
There is one more reason why you might see this error. If your flow connects to a site that the user turning on the flow doesn’t have access to you will see the same error. In short during the turn on of a flow the library connections used in any of the actions are validated and if this fails the error is thrown.