microsoftgraph / microsoft-graph-devx-api

Services API for Graph Explorer
MIT License
88 stars 31 forks source link

Complex open type non-existent property should show up in AdditionalData #613

Open fey101 opened 3 years ago

fey101 commented 3 years ago

Source: https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-beta&tabs=csharp#request-1

Input:

POST https://graph.microsoft.com/beta/teams/57fb72d0-d811-46f4-8947-305e6072eaa5/channels/19:4b6bed8d24574f6a9e436813cb2617d8@thread.tacv2/messages
Content-type: application/json

{
   "createdDateTime":"2019-02-04T19:58:15.511Z",
   "from":{
      "user":{
         "id":"id-value",
         "displayName":"Joh Doe",
         "userIdentityType":"aadUser"
      }
   },
   "body":{
      "contentType":"html",
      "content":"Hello World"
   }
}

Erroneous output:

        GraphServiceClient graphClient = new GraphServiceClient( authProvider );
         var chatMessage = new ChatMessage
         {
             CreatedDateTime = DateTimeOffset.Parse("2019-02-04T19:58:15.511Z"),
             From = new ChatMessageFromIdentitySet
             {
                 User = new Identity
                 {
                     Id = "id-value",
                     DisplayName = "Joh Doe",
                     UserIdentityType = TeamworkUserIdentityType.AadUser
                 }
             },
             Body = new ItemBody
             {
                 ContentType = BodyType.Html,
                 Content = "Hello World"
             }
         };
         await graphClient.Teams["{team-id}"].Channels["{channel-id}"].Messages
             .Request()
             .AddAsync(chatMessage);

Expected output:

        GraphServiceClient graphClient = new GraphServiceClient( authProvider );
         var chatMessage = new ChatMessage
         {
             CreatedDateTime = DateTimeOffset.Parse("2019-02-04T19:58:15.511Z"),
             From = new ChatMessageFromIdentitySet
             {
                 User = new Identity
         { 
            Id = "id-value",
                DisplayName = "Joh Doe",
            AdditionalData = new Dictionary<string, object>()
            {
                {"userIdentityType", "aadUser"}
            }
         }
             },
             Body = new ItemBody
             {
                 ContentType = BodyType.Html,
                 Content = "Hello World"
             }
         };
         await graphClient.Teams["{team-id}"].Channels["{channel-id}"].Messages
             .Request()
             .AddAsync(chatMessage);
fey101 commented 3 years ago

Related references: https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-beta&tabs=http#request-2

Similar reference where identityset doesnt nest additional data: https://docs.microsoft.com/en-us/graph/api/shift-put?view=graph-rest-1.0&tabs=http#request

zengin commented 1 year ago

Fixed for C# in SDK v5. Still an issue for Java.