2
api not working for getting messages
Question asked by Joe Copley - 1/23/2024 at 2:34 AM
Unanswered
Hello, I'm trying to get individual email messages from the API. I've been able to use the endpoint api/v1/mail/messages to get a list of messages, but when I try to use the api/v1/mail/message endpoint, I get a 401 unauthorized error. 

I'm using the same access token I use to get the message list, which works before and after I attempt to get a specific message. So, I know I'm sending a valid access token.

I'm authenticating using the email address and password of the account I am trying to get the messages from. The account is a regular user, not a domain or sys admin.

Also, the docs specify I need to send the message uid and the mid, both of which can be found in the message list response. This seems redundant, do I need to specify both, or one or the other?

Thanks in advance for any help with this.

1 Reply

Reply to Thread
1
Frank Wilson Replied
I got this working with the following, I found that I had to name the folder.

var inputPost = new
{
    folder = "Inbox",
    uid = YOUR_MESSAGE_UID
};

var jsonData = JsonConvert .SerializeObject(inputPost);

//BaseAddress and AccessToken have been set on the HttpClient _client in the constructor
var url = "/api/v1/mail/message";

var stringContent = new StringContent(
    jsonData,
    Encoding.UTF8,
    "application/json"
);

var response = await _client.PostAsync(url, stringContent);

Hope this helps!

Reply to Thread