microsoft-graph-devx-api icon indicating copy to clipboard operation
microsoft-graph-devx-api copied to clipboard

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

Open fey101 opened this issue 4 years ago • 2 comments

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:[email protected]/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 avatar Jun 18 '21 17:06 fey101

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

  • https://docs.microsoft.com/en-us/graph/api/chatmessage-post-replies?view=graph-rest-beta&tabs=http#request-1

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

fey101 avatar Jun 18 '21 17:06 fey101

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

zengin avatar Apr 05 '23 18:04 zengin