Hi, I created a sync gateway document with sync gateway admin(http://localhost:4985). I want to create a doc with http://localhost:4984. I created a doc by cURL. but i am getting error when i create doc via Guzzle HTTP client.
I am using sync gateway 1.5.1, couchbase server 5.0, php 7.1.9 and Laravel 5.5
Error :
error : unauthorized, reason: login required
this is my code
$document_id ='test_001';
$data=['item_name'=>$params['itemName']];
$cookieJar = CookieJar::fromArray(['SyncGatewaySession' => $params['sync-session']],'localhost');
$client = new \GuzzleHttp\Client (['cookie' => $cookieJar,'allow_redirects' => false,'debug' => false]);
$response = $client->put("http://localhost:4984/pos/".$document_id,['body'=>json_encode($data)]);
cURL
curl --cookie "SyncGatewaySession=97dcb859575a34690528303e3677a663cfab4879" -X POST "http://localhost:4984/pos/" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"item_name\": \"test_item\"}"
can anyone correct my code?
thank you.