Update documents Sync Gateway (SOLVED)

I’m trying to update documents: REST API(Http Request) --> Sync Gateway --> Couchbase Server 2.0, like http://docs.couchbase.com/couchbase-lite/cbl-api/#put-dbdoc .

I have tried:

PUT http://[IPServer]:4985/sync_gateway/test_doc?rev=1-4101356e9c47d15d4f8f7390d05dbbcf

Content-Type: application/json

{
“description”: “Doc Updated”
}

and also:

PUT http://[IPServer]:4985/sync_gateway/test_doc

Content-Type: application/json
If-Match: 1-4101356e9c47d15d4f8f7390d05dbbcf

{
“description”: “Doc Updated”
}

I’ve made sure that “ID” and “rev” are correct, but it doesn’t work for me. It says:
“error”:“conflict” , “reason”:“Document exists”.

How can I add new data to documents?

Thanks.

Hmmm. Can you copy/paste the full PUT string for us?

Assuming you are using the native java API for updating documents with Couchbase Lite, this is an example of how to do this:

If you are using Ektorp or the REST api, it would be a different way and I can provide docs for that too.

Which version of Couchbase Lite are you using? beta1, beta2 or the current master branch on github?

Sorry, I can’t edit the previous comment.

We would like to update a document in Couchbase Server from an app in Android device, and this document will be replicated to CBLite embedded in the app (if the replication filter allows).

I’m using Ektorp, we would like to do with Ektorp. But after much test, we also tried with REST api and neither could.

I understand that in the GrocerySync example you point me, you update a CBLite document, and CBLite makes a push replication to Couchbase Server.
We would like to update a document in Couchbase Server from, and this document will be replicated to CBLite if the filter allows.

I’m using CBLite beta2 version.

Many thanks for the quick reply.

Hi jliu,

I Reread my question, and I see I did not explain properly.

In a comment below I think I better explain my question.

Among the things I tried, I tested with a put request, like: http://docs.couchbase.com/couchbase-lite/cbl-api/#put-dbdoc, but it didn’t work for me.

Regards.

I realized that I was using an earlier version. I upgraded to the new beta 2, and it worked!!