Community articleDocument Collection POST8.5.3 UP1
Added by IBM contributorIBM | Edited by IBM contributorDave Delay on March 14, 2014
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Adds a document to a database.
Input
Method URI Description
POST /{database}/api/data/documents Adds a document to a database.
Content Type: application/json
Name Type Optional Description
database
string No Path name of a database on the server relative to the data directory.
Name Type Optional Description
computewithform
boolean Yes When true, runs the Domino form formulas against the request data before posting the data. You must identify the form.
form
string Yes Associates a Domino form with the document.
parentid
string Yes Adds the document as a response to the document specified by the parent UNID.
Name Type Optional Description
Content-Type
string No Must be application/json.
Output
Name Type Optional Description
Location
string No The URL of the new document
Code Description
201
A successful request returns response code 201 and a Location header with the URL of the new document.
Examples
This request adds a document based on the Contact form using a single HTML part for the rich text.
POST /XPagesExt.nsf/api/data/documents?form=Contact
Content-Type: application/json

{
  "FirstName":"Barney", 
  "LastName":"Bloomberg", 
  "EMail":"bb@acme.com", 
  "Number":1.75,
  "Date": ["2011-08-21T20:21:00Z", "2011-08-01T14:38:00Z"],
  "Body":{"contentType":"text/html", "data":"Just <b>sales</b>.", "type":"richtext"},
  "City":"New York City"
}

This request adds a document based on the Contact form using multipart format for the rich text, and runs the form formulas against the data.
POST /XPagesExt.nsf/api/data/documents?form=Contact&computewithform=true
Content-Type: application/json

{
  "FirstName":"Patty", 
  "LastName":"Peak", 
  "EMail":"ppeak@acme.com", 
  "Number":14.0,
  "Date": ["2011-08-21T20:21:00Z", "2011-08-01T14:38:00Z"],
  "City":"Manitou Springs",
  "Body": {
    "type":"multipart",
    "content":   [
    {
    "contentType":"multipart/alternative; Boundary=\"0__=0ABBF330DFE0278A8f9e8a93df938690918c0ABBF330DFE0278A\"",
    "contentDisposition":"inline"
    },
    {
    "contentType":"text/plain; charset=US-ASCII",
    "data":"Mostly sales. Some marketing.",
    "boundary":"--0__=0ABBF330DFE0278A8f9e8a93df938690918c0ABBF330DFE0278A"
    },
    {
    "contentType":"text/html; charset=US-ASCII",
    "contentDisposition":"inline",
    "data":"<html><body><font size=\"2\" face=\"sans-serif\">Mostly <\/font><font size=\"2\" face=\"sans-serif\"><b>sales<\/b><\/font><font size=\"2\" face=\"sans-serif\">. Some <\/font><font size=\"2\" face=\"sans-serif\"><i>marketing<\/i><\/font><font size=\"2\" face=\"sans-serif\">.<\/font><\/body><\/html>",
    "boundary":"--0__=0ABBF330DFE0278A8f9e8a93df938690918c0ABBF330DFE0278A"
    }
    ]
  }
}

This request adds a response document.
POST /restTest.nsf/api/data/documents?form=response&parentid=66C087088A5C24E085257869006AF183
Content-Type: application/json

{"Title":"Document0112"}