Hello Alan - Which PHP client library are you using?
-- Luke Bakken Engineer lbak...@basho.com On Tue, Sep 6, 2016 at 10:29 PM, HQS^∞^ <hqs...@qq.com> wrote: > dear everyone: > I follow the tutorial at > http://docs.basho.com/riak/kv/2.1.4/developing/usage/document-store/ , > Step by Step Practice , when I've Post a request for store object , but the > riak server respond 400 (Bad Request) , I review my code again and again , > but no problem found . see below: > > <?php > > > class BlogPost { > var $_title = ''; > var $_author = ''; > var $_content = ''; > var $_keywords = []; > var $_datePosted = ''; > var $_published = false; > var $_bucketType = "cms"; > var $_bucket = null; > var $_riak = null; > var $_location = null; > public function __construct(Riak $riak, $bucket, $title, $author, > $content, array $keywords, $date, $published) > { > $this->_riak = $riak; > $this->_bucket = new Bucket($bucket, "cms"); > $this->_location = new Riak\Location('blog1',$this->_bucket,"cms"); > $this->_title = $title; > $this->_author = $author; > $this->_content = $content; > $this->_keywords = $keywords; > $this->_datePosted = $date; > $this->_published = $published; > } > > public function store() > { > $setBuilder = (new UpdateSet($this->_riak)); > > foreach($this->_keywords as $keyword) { > $setBuilder->add($keyword); > } > /* > (new UpdateMap($this->_riak)) > ->updateRegister('title', $this->_title) > ->updateRegister('author', $this->_author) > ->updateRegister('content', $this->_content) > ->updateRegister('date', $this->_datePosted) > ->updateFlag('published', $this->_published) > ->updateSet('keywords', $setBuilder) > ->withBucket($this->_bucket) > ->build() > ->execute(); > > */ > $response = (new UpdateMap($this->_riak)) > ->updateRegister('title', $this->_title) > ->updateRegister('author', $this->_author) > ->updateRegister('content', $this->_content) > ->updateRegister('date', $this->_datePosted) > ->updateFlag('published', $this->_published) > ->updateSet('keywords', $setBuilder) > ->atLocation($this->_location) > ->build() > ->execute(); > > echo '</br>'; > var_dump($response); > echo '</br>'; > } > } > > $node = (new Node\Builder) > ->atHost('192.168.111.2') > ->onPort(8098) > ->build(); > > $riak = new Riak([$node]); > > > $keywords = ['adorbs', 'cheshire']; > $date = new \DateTime('now'); > > > $post1 = new BlogPost( > $riak, > 'cat_pics', // bucket > 'This one is so lulz!', // title > 'Cat Stevens', // author > 'Please check out these cat pics!', // content > $keywords, // keywords > $date, // date posted > true // published > ); > $post1->store(); > > the wireshark captured packet : > > 192.168.171.124(client ip) => 192.168.111.2(riak server ip) HTTP > 511 POST /types/cms/buckets/cat_pics/datatypes/alldoc? HTTP/1.1 > (application/json) > 192.168.111.2 192.168.171.124 HTTP 251 HTTP/1.1 400 Bad Request > > GET http://192.168.111.2:8098//types/cms/buckets/cat_pics/props > {"props":{"name":"cat_pics","young_vclock":20,"w":"quorum","small_vclock":50,"search_index":"blog_posts","rw":"quorum","r":"quorum","pw":0,"precommit":[],"pr":0,"postcommit":[],"old_vclock":86400,"notfound_ok":true,"n_val":3,"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"mapreduce_linkfun"},"last_write_wins":false,"dw":"quorum","dvv_enabled":true,"chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"big_vclock":50,"basic_quorum":false,"allow_mult":true,"datatype":"map","active":true,"claimant":"node1@192.168.111.1"}} > > please help me catch the bugs thanks in advance! > > regards > > Alan _______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com