Here's a solution working in SPServer, but CSOM.
The idea is to change the field schema's CanToggleHidden
property.
You should adapt it slightly to get the library field, not the site field.
This is way verbose, you could probably do this in 2 lines of code :p
Hope it helps.
public void TryMakeColumnVisible()
{
//params
string url = "http://yoursite";
string fieldTitle = "test_column_number";
bool hidden = false;
bool canToggle = true;
ConsoleExtensions.WriteWarning("Checking column hidden...");
context = new ClientContext(url);
context.Credentials = new System.Net.NetworkCredential(UserName, Password, Domain);
Web web = context.Web;
context.Load(web);
context.ExecuteQuery();
Field field = web.Fields.GetByTitle(fieldTitle);
context.Load(field);
context.ExecuteQuery();
string canToggleCurrent = Regex.Replace(field.SchemaXml, ".*CanToggleHidden=\"(.*?)\".*", "$1");
string newSchemaXml = Regex.Replace(field.SchemaXml, "CanToggleHidden=\"" + canToggleCurrent + "\"", "CanToggleHidden=\"" + canToggle.ToString().ToUpper() + "\"");
Console.WriteLine("Field : " + field.Title);
Console.WriteLine("Hidden : " + field.Hidden);
Console.WriteLine("CanToggleHidden: " + canToggleCurrent);
Console.WriteLine(field.SchemaXml);
//without this --> Unhandled Exception: Microsoft.SharePoint.Client.ServerException: Cannot change Hidden attribute for this field
//update schema to allow update hidden property
field.SchemaXml = newSchemaXml;
field.Update();
context.ExecuteQuery();
//update hidden property
field.Hidden = hidden;
field.Update();
context.ExecuteQuery();
Console.WriteLine(Environment.NewLine + "Setting " + fieldTitle + " with Hidden " + hidden + " and CanToggleHidden " + canToggle);
Console.WriteLine("Hidden : " + field.Hidden);
Console.WriteLine(newSchemaXml);
}