Hello again,
i tried calling the SendMessage method, but keep failing with the error:
{"message":"Value cannot be null.\r\nParameter name: key"}
i thought maybe the Actions list is required to have at least 1 value, so i addedd one, but it didn't help.
the only other "key" in the documentation is in "originalCidLinks " but i don't even know what it is...
i don't know which "key" is missing... here is my C# code:
api_authenticate_user_response authResult = await Authenticate_User_Async(Username, Password);
if (authResult.success == false)
{
//Do Nothing - display error message
lblResult.Text = "failed to get token";
return;
}
else
{
//Save Access Token
accessToken = authResult.accessToken;
//lblResult.Text = accessToken;
}
//read the current message again, to extract the required information
var url = GetOperationURI("mail/message-put");
EmailMessage message = new EmailMessage();
message.To = txtClientEmailAddress.Text;
message.From = Username;
message.Subject = $"RE: Lost & Found: Report #LF{report_id}";
message.ReplyUid = Convert.ToInt32(hidLatestMsgId.Value);
message.ReplyFromFolder= hidLatestMsgFolder.Value;
message.Folder = "Sent Items";
message.MessageHTML = radEditorNewMail.Content;
message.Actions.Add("Replied", true);
var jsonData = JsonConvert.SerializeObject(message);
std.dbg("sonData =", jsonData);
using (var request = new HttpRequestMessage(HttpMethod.Post, url))
{
request.Content = new StringContent(jsonData, Encoding.UTF8, "application/json");
request.Headers.Add("Authorization", "Bearer " + accessToken);
using (var client = new HttpClient())
{
var response = await client.SendAsync(request);
if (response.IsSuccessStatusCode)
{
// Successful response
var responseContent = await response.Content.ReadAsStringAsync();
//std.dbg(responseContent);
SendMessageResult result = JsonConvert.DeserializeObject<SendMessageResult>(responseContent);
if (!result.Success)
{
lblSendResults.Text = $"Sent failed. Error code: {result.ResultCode}.<br/>Message:{result.Message}.<br/>debugInfo:{result.DebugInfo}.";
lblSendResults.CssClass = "error";
}
return ;
}
else
{
// Unsuccessful response
var responseContent = await response.Content.ReadAsStringAsync();
//std.dbg("No!", responseContent);
lblSendResults.Text = responseContent;
lblSendResults.CssClass = "error";
return;
}
//response.EnsureSuccessStatusCode();
}
}
Any idea what is missing?
thanks,
ilan