InternalCreate method
Create a PostItem response.
The parent folder id.
The message disposition.
Implementation
Future<PostItem> InternalCreate(
FolderId? parentFolderId,
MessageDisposition? messageDisposition,
) async {
(PropertyBag[ResponseObjectSchema.ReferenceItemId] as ItemId).Assign(
_referenceItem.Id!,
);
// ExchangeService.InternalCreateResponseObject requires a non-null
// MessageDisposition; a post reply is created without one (the C# API
// passes null), so the request is built here.
CreateResponseObjectRequest request = CreateResponseObjectRequest(
Service,
ServiceErrorHandling.ThrowOnError,
);
request.ParentFolderId = parentFolderId;
request.Items = [this];
request.MessageDisposition = messageDisposition;
ServiceResponseCollection<CreateResponseObjectResponse> responses =
await request.Execute();
List<Item> items = responses[0].Items!.whereType<Item>().toList();
PostItem? postItem = EwsUtilities.FindFirstItemOfType<PostItem>(items);
// This should never happen. If it does, we have a bug.
EwsUtilities.Assert(
postItem != null,
"PostReply.InternalCreate",
"postItem is null. The CreateItem call did not return the expected PostItem.",
);
return postItem!;
}