Пытался использовать Microsoft Graph Email API, НО получаю следующую ошибку.
Полезная нагрузка ODATA
"message": {
"subject": "Send email",
"body": {
"contentType": "text",
"content": "wuirbmndf"
},
"toRecipients": [
{
"emailAddress": {
"address": "emailid"
}
}
],
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "attachment.txt",
"contentType": "text/plain",
"contentBytes": "SGVsbG8gV29ybGQh"
}
],
"from": {
"emailAddress": {
"address": "sender email id"
}
}
}
Мой код выглядит как - >
client.BaseUrl = new Uri(String.Format("https://graph.microsoft.com/v1.0/me/sendmail"));
RestRequest request = new RestRequest();
request.Method = Method.POST;
request.AddParameter("Authorization", string.Format("Bearer " + emailObj.AccessToken), ParameterType.HttpHeader);
request.AddParameter("application/json", json, ParameterType.RequestBody);
//request.AddHeader("ContentType", "application/json");
//request.JsonSerializer.ContentType = "string";
var result = client.Execute(request);
И я получаю InternalServerError с ошибкой Ссылка на объект не установлена на экземпляр объекта.
{
"error": {
"code": "InternalServerError",
"message": "Object reference not set to an instance of an object.",
"innerError": {
"request-id": "22ec4d88-2140-497f-bf28-80c83d7aa6a9",
"date": "2020-05-27T04:24:14"
}
}
}
заранее спасибо.