Create a second connection using ODATA. Make sure it produces exactly the same final result as your original query. Then in Advanced Editor copy the resulting M code and place it into the original query. Once everything works you can remove the new query again.
Lots of backups!!! This is not a simple process and can break not just power query, but also visuals, measures, groups, renamed columns etc etc.