0

There are No examples to work with Microsoft.Graph in .NET core C# the API is all JSON. I was able to create a choice site column but the default value did not work

 Microsoft.Graph.ColumnDefinition column = new Microsoft.Graph.ColumnDefinition
                {
                    ColumnGroup = "ECGmc",
                    DisplayName = "Document Stage",
                    Name = "DocumentStage",
                    Choice = new ChoiceColumn { ODataType= "microsoft.graph.choiceColumn", AllowTextEntry = false,
                        Choices = new List<string>() { "Working Draft", "Discussion Draft", "Final" }, DisplayAs = "dropDownMenu" },
                    DefaultValue = new DefaultColumnValue { Value = "Working Draft", ODataType= "microsoft.graph.defaultColumnValue" },
                    Description = "Will differ the stages the Document changes",
                    Required = true
                };
                Microsoft.Graph.ColumnDefinition newColumn = await graphClient.Groups[project.GroupID].Sites["root"].Columns.Request().AddAsync(column);

Works but the DefaultValue is empty.

Does anyone know how to set the DefaultValue? Does anyone know where I can find C# examples for Microsoft.Graph?

Ofer Gal
  • 707
  • 1
  • 10
  • 32

2 Answers2

0

I test it in my local environment but I got the "DefaultValue" successfully. I didn't add "ODataType". Below I post the screenshot of my code and "Console.WriteLine" result: enter image description here

Here the "DefaultValue" is not empty. Hope it would be helpful to you.

Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • Thank you! I managed to get the site columns and content types from another site. Instead of recreating them every time. – Ofer Gal Oct 21 '19 at 21:27
0

I know this is an old issue, but at this moment I am having the same issue for a ColumnDefinition. I can set all settings for the Column except DefaultValue as described in the initial post by Ofer. As I can see

I have tried in:

I also traced the Graph API traffic using Fiddler and I can see that the DefaultValue is included in the calls, but ignored.

Could others confirm the error or provide a working solution for updating the DefaultValue.

EDIT: After investigating, then I can attach the DefaultValue if I set it when creating the List - however it does not solve the issue regarding Adding/Editing a List Column.

Best Regards, Martin

mallesite
  • 33
  • 4