Setting all material parameters to <By Category>

I am attempting to use a script to get rid of all of the previously set materials in a project and replace them to be set to When I do this I get an error message in my final step that says “Warning: Parameter.SetValue operation failed.
The call is ambiguous between the following methods or properties: ‘Revit.Elements.InternalUtilities.ElementUtils.SetParameterValue(Autodesk.Revit.DB.Parameter, Revit.Elements.Element)’ and ‘Revit.Elements.InternalUtilities.ElementUtils.SetParameterValue(Autodesk.Revit.DB.Parameter, string)’” If anyone has any advice on how to fix this please let me know!

I have a similar question. How to set a material parameter “By Category”?