DbClient.save(obj) with _id issue

30 views
Skip to first unread message

snanke

unread,
Aug 23, 2016, 6:12:51 PM8/23/16
to LightCouch
I am currently using Light Couch, running from a batch file. I have tried hard-coding the example for saving to my PouchDB Server:

JsonObject json = new JsonObject();
json.addProperty("_id", "doc-id");
Response response = dbClient.save(json);
When I ran this code, previously, in my netbeans project, I got the expected results. Now, In my current project, I am able to save, but it auto-generates the id, as if I was using post command (according to javadocs). I can't seem to find what the difference is between my to projects. I am guessing it is some remote configuration difference, as I am using a copy-paste version of my code.


PouchDB Server:
Netbeans:
{
"_id": "doc-id",
"_rev": "1-cb9727276ca8c799c671697b2e77c8c6",
"value": {
 "rev": "1-cb9727276ca8c799c671697b2e77c8c6"
},
"key": "doc-id"
}
Current Project:
{
 "_id": "422bbd819c5c4e3e913b206de6e77561",
 "members": {
"_id": {
 "value": "doc-id"
}
 },
 "_rev": "1-8c7e621eeafde31994912b49e47948f3"
}

Things to Note:
- System.out.println(json.toString()); prints out {"_id":"doc-id"}
- I have tried using {"id":"doc-id"} //no dash
- I am using the same version for java and all my jar files, as listed below
- Save is working, it simply is not using my id
The versions I am using:
- Java 8
- gson-2.7.jar
- httpclient-4.5.2.jar
- httpcore-4.4.5.jar
- commons-logging-1.2.jar
- commons-codec-1.9.jar
- lightcouch-0.1.8.jar
Has anyone come across something like this, or know what might be causing my issue? Thanks in advance!
Reply all
Reply to author
Forward
0 new messages