Just a quick tip,
I was working on Power automate, and after a while i found this “Could not find any valid connection for connection reference name ‘shared_office365_1’ in APIM tokens header.” error, when testing it, though it is successfully saving.
Kindly export the flow, choose the .zip option to export. and import it back. This should work.