I've been futzing around with this for a few days and my finding is the SP.RequestExecutor has slightly different parameter names than the normal 'direct' ajax query.
For example, instead of
type: "POST"
use
method: "POST"
and for the actual data package to post, instead of
data: JSON.stringify(item)
use
body: JSON.stringify(item)
finally, while the GetByTitle embedded function uses quotes for the title parameter within the parenthesis, the items does not. So instead of
.../items('123')
use
.../items(123)
For completeness, here is the block that I used to update via rest using javascript across a domain with the SP.RequestExecutor object:
new SP.RequestExecutor(closureThis.appweburl).executeAsync(
{
url: closureThis.appweburl + "/_api/SP.AppContextSite(@target)/web/lists(guid\'" + listIdGuid + "\')/items(" + itemId + ")?@target='" + closureThis.hostweburl + "'",
method: "POST",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": closureThis.getDigestValue(),
"X-HTTP-Method": "MERGE",
"If-Match": "*"
},
body: updateBlock,
success: function (data) { closureThis.updateDataObjectCallback(data); },
error: spRequestorErrorHandler
}
);
Where closureThis is an object I use to store SharePoint variables and handle callbacks Where updateBlock is the JSON.stringify(data) value
My updateBlock value looks like this:
"{\"__metadata\":{\"type\":\"SP.Data.TasksListItem\"},\"Title\":\"First Task\"}"