My objective is to process emails in a folder and then move them to another folder to which I have the id. To ease the workload I'm trying to make use of the batch functionality.
Unfortunately, every time I try to run the batch function I'm presented with an exception with the message Code: invalidRequest Message: Unable to deserialize content.
.
The code in question, simplified for just one request, can be found below.
var batch = new BatchRequestContent();
var json = JsonSerializer.Serialize( new { destinationId = Graph.Me.Messages[messageId].Move(folderId).Request().RequestBody.DestinationId } );
var jsonMessage = Graph.HttpProvider.Serializer.SerializeAsJsonContent(json);
var request = Graph.Me.Messages[messageId].Move(folderId).Request().GetHttpRequestMessage();
request.Method = HttpMethod.Post;
request.Content = jsonMessage;
batch.AddBatchRequestStep(request);
var res = await Graph.Batch.Request().PostAsync(batch);
I've narrowed down the problem to be about the request.Content
because without that it will go through, though getting back with a 400 error about missing body.
Copying the string from batch.ReadAsStringAsync()
and pasting that directly into the Graph Explorer and using that to run the query returns a 200 success.
Based on what I've tried I'm starting to lean on it being a limitation of the SDK's batch. Any ideas?