1
votes

i am trying to use the REST-API of my domino lotus notes server (9.0.1FP8)

It works for simple text-fields but if I try to add an rich-text-item as json, the domino server receives only the text-fields and the richt-text field is empty.

I try it with Postman and a Postrequest to http://localhost/Test/JSON_Vie…s/name/List?form=mainForm, where I send the json

{
    "title":"test rich text",
    "artist":"rich texter",
    "ntracks":1,
    "attachments": {
        "type": "multipart",
        "content": [
            {
                "contentType": "multipart/alternative; Boundary=\"0__=4EBB0925DFBB40F18f9e8a93df938690918c4EBB0925DFBB40F1\"",
                "contentDisposition": "inline"
            },
            {
                "contentType": "text/plain; charset=US-ASCII",
                "data": "test rich text",
                "boundary": "--0__=4EBB0925DFBB40F18f9e8a93df938690918c4EBB0925DFBB40F1"
            },
            {
                "contentType": "text/html; charset=US-ASCII",
                "contentDisposition": "inline",
                "data": "<html><body><font size=\"2\" face=\"sans-serif\"><b>test rich text</b></font></body></html>",
                "boundary": "--0__=4EBB0925DFBB40F18f9e8a93df938690918c4EBB0925DFBB40F1"
            }
        ]
    }
}

The mask mainForm has the text-fields "title", "artist" , "ntracks" and the rich text-field "attachments".

How can I send an image as json and what is "boundary"?

Have you any idea , what's going wrong?

2
Are you using DAS or ExtLib?Thomas Adrian
Have you tried something simple like this? "attachments":{"contentType":"text/html", "data":"<b>test rich text</b>", "type":"richtext"}Per Henrik Lausten
@ThomasAdrian: I just want to test it for simple html code firt. But actual I want to send an image per json, and I don't get how to do that. I use DAS.einue
@PerHenrikLausten I tried your simple json for attachments but the field is still empty.einue
@PerHenrikLausten: this is really interesting. If I use put on an existing document and add my attachment field in the json, it works! Is it somehow possible in a POST?einue

2 Answers

2
votes

According to the documentation from IBM you need to use PUT (instead of POST) in order to update the fields.

0
votes

After experimenting a little bit, I now know what was wrong. If I do the POST on the address http://localhost/Test/JSON_Views.nsf/api/data/documents?form=mainForm it works with the attachment. If I use http://localhost/Test/JSON_Views.nsf/api/data/collections/name/List?form=mainForm&computewithform=true the attachment field is ignored. But maybe you can explain me, what the extra field boundary is and if I can set the contentLocation by the name of my attachment?