Product tutorials, how-tos, and fully-documented APIs.

HTTP Store Object

    Stores an object under the specified bucket / key. Storing an object comes in two forms, depending on whether you want to use a key of your choosing, or let Riak assign a key to a new object.

    Request

    POST /riak/bucket               # Riak-defined key, old format
    POST /buckets/bucket/keys       # Riak-defined key, new format
    PUT /riak/bucket/key            # User-defined key, old format
    PUT /buckets/bucket/keys/key    # User-defined key, new format
    

    For the sake of compatibility with older clients, POST is also acceptable in the form where the key is specified.

    Important headers:

    Optional headers (only valid on PUT):

    Optional query parameters:

    This request must include a body (entity).

    Response

    Normal status codes:

    Typical error codes:

    Important headers:

    If returnbody=true, any of the response headers expected from HTTP Fetch Object may be present. Like when fetching the object, 300 Multiple Choices may be returned if siblings existed or were created as part of the operation, and the response can be dealt with similarly.

    Example: Storing Without Key

    $ curl -v -d 'this is a test' -H "Content-Type: text/plain" http://127.0.0.1:8098/riak/test
    * About to connect() to 127.0.0.1 port 8098 (#0)
    *   Trying 127.0.0.1... connected
    * Connected to 127.0.0.1 (127.0.0.1) port 8098 (#0)
    > POST /riak/test HTTP/1.1
    > User-Agent: curl/7.19.4 (universal-apple-darwin10.0) libcurl/7.19.4 OpenSSL/0.9.8l zlib/1.2.3
    > Host: 127.0.0.1:8098
    > Accept: */*
    > Content-Type: text/plain
    > Content-Length: 14
    >
    < HTTP/1.1 201 Created
    < Vary: Accept-Encoding
    < Server: MochiWeb/1.1 WebMachine/1.9.0 (participate in the frantic)
    < Location: /riak/test/bzPygTesROPtGGVUKfyvp2RR49
    < Date: Fri, 30 Sep 2011 15:24:35 GMT
    < Content-Type: application/json
    < Content-Length: 0
    <
    * Connection #0 to host 127.0.0.1 left intact
    * Closing connection #0
    

    Example: Storing With Key

    $ curl -v -XPUT -d '{"bar":"baz"}' -H "Content-Type: application/json" -H "X-Riak-Vclock: a85hYGBgzGDKBVIszMk55zKYEhnzWBlKIniO8mUBAA==" http://127.0.0.1:8098/riak/test/doc?returnbody=true
    * About to connect() to 127.0.0.1 port 8098 (#0)
    *   Trying 127.0.0.1... connected
    * Connected to 127.0.0.1 (127.0.0.1) port 8098 (#0)
    > PUT /riak/test/doc?returnbody=true HTTP/1.1
    > User-Agent: curl/7.19.4 (universal-apple-darwin10.0) libcurl/7.19.4 OpenSSL/0.9.8l zlib/1.2.3
    > Host: 127.0.0.1:8098
    > Accept: */*
    > Content-Type: application/json
    > X-Riak-Vclock: a85hYGBgzGDKBVIszMk55zKYEhnzWBlKIniO8mUBAA==
    > Content-Length: 13
    >
    < HTTP/1.1 200 OK
    < X-Riak-Vclock: a85hYGBgymDKBVIszMk55zKYEhnzWBlKIniO8kGF2TyvHYIKfwcJZwEA
    < Vary: Accept-Encoding
    < Server: MochiWeb/1.1 WebMachine/1.9.0 (participate in the frantic)
    < Link: </riak/test>; rel="up"
    < Date: Fri, 30 Sep 2011 15:24:35 GMT
    < Content-Type: application/json
    < Content-Length: 13
    <
    * Connection #0 to host 127.0.0.1 left intact
    * Closing connection #0
    {"bar":"baz"}