0

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?

lucas
  • 55
  • 2
  • 10
  • Aside from overall limits on POST data, rich text fields also have a limit of 64 kB per paragraph, so maybe you could be hitting that. I haven't tried updating rich text fields through the data service, but I guess you'd need HTML `p` tags to indicate paragraphs. – Scott Leis Jul 20 '21 at 00:49
  • I assumed that it has something to do with the rich text fields. The limitation per paragraph would totally explain my problem. I want to store XML files in my database. Can I customize my rich text field in order to save bigger paragraphs, or are there any alternatives for saving large strings without paragraphs / xml files? – lucas Jul 20 '21 at 06:26
  • If you install the OpenNTF Domino API (https://oda.openntf.org/) on your server you can store the data in a text field. Those have a limitation of 15 KB, but the OpenNTF Domino API will automatically serialize that for you into a file attachment. But if you go this way, you cannot use the data service anymore and have to write your own. – Mark Leusink Jul 20 '21 at 06:30

2 Answers2

3

I think you have to change the maximum in a couple of locations.

  • In the server document of your server (in names.nsf) you can set the maximum size of request content being send to the server. The default is 10,000 KB. Set it to 0 to not have a limit.

    See: server document > Internet Protocols > HTTP > at the bottom of the right column.

enter image description here

  • If you are using internet site documents (which you should), change the field "Maximum POST data". Default is also 10,000 KB. 0 = unlimited.

    See: Internet Site > Domino Web Engine > "POST Data" section.

enter image description here

  • Finally, in the XSP properties of an application (NSF) there's also a setting for the maximum size of a file upload. Not sure if you also need to change that value, but it might be related.

enter image description here

Changing the settings in the server document will require a server restart.

Mark Leusink
  • 3,747
  • 15
  • 23
  • Thanks for your reply. I checked the settings, but they look quite similar to yours. I tested out something else: If I add a second String to my data which is shorter in combination with the long one: The data field for the long one still is overwritten with an empty string. But my smaller string is saved in the database. e.g.: ``data = {"description": "longString", "TestField": "shortString"}. So I would guess that it is not caused by a size limitation. Do I maybe have to change any setting for my rich text field? – lucas Jul 19 '21 at 11:00
1

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.

Dave Delay
  • 1,292
  • 8
  • 12