Recently, I started working with Domino Access Services. So far, it is working fine: I can use my GET and POST requests. But I noticed a problem: When posting a large string (I assume 100-200kb+), the data field will be empty even if something else stood there before. As a response, I get a status code 200. If I insert this large string manually into the data field, it is saved. I can access it with the GET request without any problems. The data field is from type "Rich Text".
My POST-Request: (I also tried it with Postman; it works with small strings)
var largeString = "any large string";
var data = JSON.stringify({
"description": largeString
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
var unid = "#{javascript:document1.getDocument().getUniversalID();}";
xhr.open("POST", "./api/data/documents/unid/" + unid);
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-http-method-override", "PATCH");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(data);
I am wondering: Are there any size limitations for POST? Do I miss any headers for larger requests?
According to your example, you are sending the following JSON payload:
{
"description": "any large string"
}
That writes a Text field -- not a Rich Text field. There is definitely a limit to the size of a Text field in Notes and Domino.
Technically, you cannot write a Notes Rich Text field with the data API, but you can write a MIME field. Try sending the following JSON payload instead:
{
"description": {
"type": "multipart",
"content": [
{
"contentType": "text/plain",
"data": "any large string"
}
]
}
That writes a single text/plain
part wrapped in a multipart
MIME field. It should work no matter the length of the data
property. Just keep in mind the MIME field is not traditional Notes Rich Text. In most cases, it is interchangeable with Rich Text, but that depends on what you are doing with the data.
Caveat: I haven't tried sending the exact payload in my example, but I'm 99% sure it should work. For more information on the multipart
data type see Receiving a response body.