You are viewing the documentation for a prerelease version.

View Latest

Creating a Collection

Collections can be created by means of the REST API.

Description

Collections are created by means of the POST /pools/default/buckets/<bucket_name>/collections/<scope_name> HTTP method and URI.

HTTP Method and URI

POST /pools/default/buckets/<bucket_name>/collections/<scope_name>

Requires the name parameter, whose value is the name of the collection to be created.

Syntax

Curl request syntax is as follows:

curl -X POST -v -u [admin]:[password]
  http://<hostname-or-ip>:8091/pools/default/buckets/\
    <bucket_name>/collections/<scope_name>
  -d name=<name-of-collection>

Examples

Curl request example:

curl -X POST -v -u Administrator:password \
http://localhost:8091/pools/default/buckets/\
testBucket/collections/my_scope \
-d name=my_collection_in_my_scope_1

Raw HTTP request example:

POST /pools/default/buckets/testBucket/collections/my_scope HTTP/1.1
Host: localhost:8091
Content-Type: application/json
Authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==

Response example:

{"uid":18}

Response codes:

HTTP/1.1 200 OK
HTTP/1.1 401 Unauthorized
HTTP/1.1 404 Object Not Found

Possible errors:

Requested resource not found.
"name":"Length must be in range from 1 to 30"
"name":"Can only contain characters A-Z, a-z, 0-9 and the following symbols _ - %"