How many times have you been developing a Flow, and you get this horrible error while testing.

Request to Azure Resource Manager failed with error: '{"error":{"code":"InvokerConnectionOverrideFailed","message":"Could not find any valid connection for connection reference name 'shared_sharepointonline' in APIM tokens header."}}'.

Ugly right? So today, I want to show you why this happens and how to fix it.

Replicating the error.

The first step to fixing something is to replicate it. So let’s do that. First, let’s create a “Manually trigger a Flow” trigger and a “Compose” action. Nothing too fancy.

We want to receive an ID and show it in the compose. Now let’s test it.

We provide an ID and then run the Flow.

It works as expected, so now we can add a “Get item” action that fetches that ID from a SharePoint list. Since the trigger parameter is a string, we need to convert it to an integer using the “int” function. Here’s what it looks like:

Note that you can define the parameter as an integer, but I wanted to show you that sometimes you need to convert information for the actions to work.

Now let’s test it, and since we already have a run from last time with an ID, we can use it here.

And we get the error:

Before going to the next section, can you understand why it returned the error?

No worries, I’ll explain why.

The solution

Let’s recap what we did:

  1. Created a Flow with a trigger and an action
  2. Run the Flow
  3. Added another action
  4. Got an error

The issue was not that we added a new action. It’s properly configured and with the correct values. The problem is that when Flow runs “with a recent used trigger,” it will run with all the connections that it had configured at the time. Notice that we only added that action (and corresponding connection) after running the Flow.

So what’s happening is that Flow is saying that it could not find a connection in the “context” of the previous run.

Let’s see this from a different angle. If you say to Flow, “hey, run this Flow with the previous conditions.” Flow didn’t have a connection to SharePoint, so that it will return 🤷‍♀️ and panics with that error.

Let’s see the difference if we run the same but use the “Manually” option again.

We get an intermediate step.

When we get this step, we usually ignore it since Power Automate does all the work for us, but notice what’s happening. Power Automate tells us that it’s setting up a new connection to SharePoint since it has an action that requires that. So when we press “Continue,” we get the following:

The Flow now has a connection to SharePoint, and it’s able to fetch the data. So now, if we add more actions that use that connection and run the solution, all will work.

Confused? I hope not, but here’s more.

I know that is confusing, but once you understand what’s happening, you’ll be careful when running the Flows or fixing them when you get this error. The issue is that we’re trying to use the SharePoint list action with the context where the “pipes” were not connected yet. So although the exception looks cryptic, looking a bit further, we can try to understand where the issue comes from.

Request to Azure Resource Manager failed with error: '{"error":{"code":"InvokerConnectionOverrideFailed","message":"Could not find any valid connection for connection reference name 'shared_sharepointonline' in APIM tokens header."}}'.

I’ll remove the stuff that is not interesting:

...Could not find any valid connection for connection reference name 'shared_sharepointonline'...

The “shared_sharepointonline” gives you a clue that the issue is with a SharePoint action, and the “could not find any valid connection” gives you another hint that there is an issue with the connection.

Final thoughts

Although this looks like an error while testing, it’s not quite an error, the way that Power Automate deals with connections. One can argue that Power Automate should be competent to identify that a connection is missing and add it. I agree, but in the meantime, while Microsoft doesn’t deal with this, you’ll know what to do.

Have a suggestion of your own or disagree with something I said? Leave a comment or interact on Twitter and be sure to check out other Power Automate-related articles here.

Photo by Cookie the Pom on Unsplash

Manuel Gomes

I'm a Project Manager with experience in large projects and companies. I've worked in the past for companies like Bayer, Sybase (now SAP) and I'm currently working for Pestana Hotel Group.

View all posts by Manuel Gomes →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: