Community articleSending a POST request in JavaScript
Added by IBM contributorIBM on September 27, 2013
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Here is sample code to send a POST request to the Domino® Data Service.
This particular request is a Document Collection POST das901Create New Article. It is coded in server-side JavaScript™ for XPages.

// Establish connection with Domino documents resource
var url = new
var = url.openConnection();
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
var writer = new;
// Send JSON object as string
writer.write('{"FirstName":"Mary", "LastName":"MacBrown", "EMail":"", "City":"Glascow"}');
// Display the response - should be 201 for success
requestScope.status = conn.getResponseCode() + " " + conn.getResponseMessage();

Explanatory notes:
  • For a POST request, establish a network connection using, set the Content-Type request property to application/json, and set the Accept request property to application/json.
  • The body written to the connection should be a JSON object or array as a string.
  • The response code should be 201 for a successful POST.

Parent topic: Programming Domino Data Service