Can't use Expand to get singleValueExtendedProperties on a single email query (SDK 5.1.0)

Steve Clarke 10 Reputation points
2023-03-15T06:44:04.8633333+00:00

Hello,

I am using the Microsoft.Graph 5.1.0 SDK in a C# project and need to get internet headers of a single email.

The issue is that to do this I need to use Expand in the query parameters, but this does not appear to exist for the Microsoft.Graph.Users.Item.Messages.Item.MessagesRequestBuilder and the attached code will therefore give you an error:

Error CS1061 'MessageItemRequestBuilder.MessageItemRequestBuilderGetQueryParameters' does not contain a definition for 'Expand' and no accessible extension method 'Expand' accepting a first argument of type 'MessageItemRequestBuilder.MessageItemRequestBuilderGetQueryParameters' could be found (are you missing a using directive or an assembly reference?)

var emails = graphServiceClient.Users[userEmail].MailFolders["sentitems"].Messages
                .GetAsync((requestConfiguration) =>
                {
                    requestConfiguration.QueryParameters.Select = selectProperties;
                    requestConfiguration.QueryParameters.Filter =
                        $"id eq {id}";
                    requestConfiguration.QueryParameters.Expand = new string[]
                    {
                        "singleValueExtendedProperties($filter=id eq 'String {00020386-0000-0000-C000-000000000046} Name x-internet-header-name')"
                    };
                    requestConfiguration.QueryParameters.Top = 1;
                })
                .Result;

I am able to successfully use Expand on queries on a mailbox, but I only want to retrieve a specific email (but it does show that Microsoft.Graph.Users.Item.MailFolders.Item.Messages.MessagesRequestBuilder is slightly different here).

I can also use Graph Explorer to retrieve this information on a single email which shows that Graph itself should be able to handle the this query.
(swap out {UserId} and {EmailId})

https://graph.microsoft.com/v1.0/Users/{UserId}/Messages/{EmailId}?$select=id,subject,singleValueExtendedProperties&$expand=singleValueExtendedProperties($filter=id eq 'String {00020386-0000-0000-C000-000000000046} Name x-internet-header-name')

Is the SDK able to have the Expand added to Microsoft.Graph.Users.Item.Messages.Item.MessagesRequestBuilder?

Thank you.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,536 questions
0 comments No comments
{count} vote