c#
var token = await GetUserTokenAsync(); //gets the latest token from the GraphClient
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
using (var content = new StringContent(body))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var postUrl = new UriBuilder($"https://graph.microsoft.com/v1.0/groups/{groupId}/threads/{threadId}/reply").ToString();
var resp = await client.PostAsync(postUrl, content);
if (!resp.IsSuccessStatusCode)
{
//same Url and body
Console.WriteLine($"Error: Unable to post reply to group {groupId} thread {threadId}. The server said {await resp.Content.ReadAsStringAsync()}");
String curlCommand = $"curl -i -X POST -H \"Authorization: Bearer {token}\" -H \"Content-Type: application/json\" -d '{body}' \"https://graph.microsoft.com/v1.0/groups/{groupId}/threads/{threadId}/reply\"";
Console.WriteLine($"Try this with curl: {curlCommand}");
}
}
}
c#
var token = await GetUserTokenAsync(); //gets the latest token from the GraphClient
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
using (var content = new StringContent(body))
{
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var postUrl = new UriBuilder($"https://graph.microsoft.com/v1.0/groups/{groupId}/threads/{threadId}/reply").ToString();
var resp = await client.PostAsync(postUrl, content);
if (!resp.IsSuccessStatusCode)
{
//same Url and body
Console.WriteLine($"Error: Unable to post reply to group {groupId} thread {threadId}. The server said {await resp.Content.ReadAsStringAsync()}");
String curlCommand = $"curl -i -X POST -H \"Authorization: Bearer {token}\" -H \"Content-Type: application/json\" -d '{body}' \"https://graph.microsoft.com/v1.0/groups/{groupId}/threads/{threadId}/reply\"";
Console.WriteLine($"Try this with curl: {curlCommand}");
}
}
}