Search code examples
restemaillotus-domino

Updating mail draft using Domino REST API causes message to appear in Send folder


I am using the Domino Mail REST API and am able to create a new draft mail which appears in the Drafts folder.

When I update the draft mail it appears in the Sent folder and is no longer visible in the Drafts folder.

This is unexpected. The message was not sent. I have also tried setting the From and To fields to null and the sresult is always the same.

Partial code: Gson gson = new Gson(); String json = gson.toJson(message);

        // if message has an id then do update
        if (href != null && href.trim().length() > 0) {
            url = createFullQualifiedRequestUrl(href);
            HttpPut request = new HttpPut(url);
            request.setHeader("Content-Type", "application/json");
            request.setEntity(new StringEntity(json, "utf-8"));
            response = this.executeRequest(request, username);

        } else {
            MailboxFolder folder = getFolder("drafts", username);
            url = this.createFullQualifiedRequestUrl(folder.getLink()
                    .getHref());
            HttpPost request = new HttpPost(url);
            request.setHeader("Content-Type", "application/json");
            request.setEntity(new StringEntity(json, "utf-8"));
            response = this.executeRequest(request, username);
        }

        if (response != null) {
            SendMessageResult result = parseResponse(response);
            if(href != null)
                result.setLocation(href);
            return result;
        }

Solution

  • That's a bug in the REST mail API and Richard is correct about the root cause. The bug will be fixed in the next release of the extension library (901v00_12). I can't say exactly when release 12 will be available, but it should be soon.