An API that connects multiple Microsoft services, enabling data access and automation across platforms
Graph API return duplicate response for email - Same content with different ids
I am using microsoft graph APIs for email communications.
I am calling the graph api for a reply communication. The API to form reply is called and further id is taken from the response to finally send the draft mail. But when I fetch back the mails for same conversation mail thread using conversation id, it returns a mail with same content but with 2 different IDs. Whereas, both the APIs were called only once. Depicting that the mail was sent twice. Although the recipient mailbox also receives one single mail.
This is causing a duplicate mail scenario for us, when we show the conversation thread on UI. How do we resolve this? And why are we getting duplicate mail as a sent one, where we are calling the API once.
API that we use to send reply communication mails using shared emails -
- messages/{Id}/createReply
- /users/{shared_mail}/messages/{id}/send
Further when we use get api to fetch records for same account which is -
users/<shared_mail>/messages
Please help on this on an urgent basis. Code snippets are provided below -
Code to create reply
var client = new RestClient();
string replyPayload = GetPayloadWithOdataType(Input);
string requestUrl = $"{GetEndPoint(Input.email_module)}messages/{Input.id}/createReply";
var request = new RestRequest(requestUrl, Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", $"Bearer {Input.access_token}");
request.AddStringBody(replyPayload, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
if (response.ResponseStatus.ToString().Equals("error", StringComparison.OrdinalIgnoreCase))
{
throw this.ThrowLogicalError(response.StatusCode, response.Content);
}
Code to send reply
var client = new RestClient();
string requestURL = $"{GetEndPoint(Input.email_module)}messages/{id}/send";
var request = new RestRequest(requestURL, Method.Post);
request.AddHeader("Authorization", $"Bearer {Input.access_token}");
request.AddParameter("text/plain", @"", ParameterType.RequestBody);
RestResponse response = await client.ExecuteAsync(request);