How to use AssetDatabase.RenameAsset?

var path = AssetDatabase.GetAssetPath(target); //target is asset type of Scriptable Object
var name = “My asset new name”;

target.name = AssetDatabase.RenameAsset(path, name);
AssetDatabase.SaveAssets();

As you could guess, code do not rename my asset. So, what is wrong?

I’ll answer this question for informational purposes, in case anyone finds this question.

AssetDatabase.RenameAsset() doesn’t return the new name, it tries to rename the asset, and it will return an empty string if it was successful, or an error code if it wasn’t.