Vague Exception when I use document.putProperties(map)?

44 views
Skip to first unread message

Pankaj Jakhar

unread,
Mar 27, 2014, 2:29:29 AM3/27/14
to mobile-c...@googlegroups.com
I am trying to put properties Map in a CBLite document but getting exception. Please answer me what should I do. For formatting reasons I have put this question on StackOverflow.

http://stackoverflow.com/questions/22679850/com-couchbase-lite-couchbaseliteexception-when-document-putpropertiesmap-is-ca


Map<String, Object> map = new HashMap<String, Object>();
map = (Map<String, Object>) gson.fromJson(json, map.getClass());
//map.put("_id", UUID.randomUUID().toString());

Document document = mDatabaseLocal.createDocument();
try {
document.putProperties(map);
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}

Exception:

com.couchbase.lite.CouchbaseLiteException


Pankaj Jakhar

unread,
Mar 27, 2014, 3:03:11 AM3/27/14
to mobile-c...@googlegroups.com
I copied the exception message. Might be it will help you understand where the problem occurred.

com.couchbase.lite.CouchbaseLiteException
com.couchbase.lite.CouchbaseLiteException
null
[1462915328, 451, 1462915272, 5, 1463020336, 137, 1463020280, 9, 1462744624, 39, 1462943280, 4, 1463283568, 58, 1463284808, 9, 1459791184, 28, 1463191704, 0, 1463287160, 0, 1463294584, 8, 1463285984, 2, 1463298952, 2, 1461828864, 24, 1459658792, 6, 1461922408, 22, 1459660472, 15, 1461916072, 3, 1461898944, 8, 1459489944, 18, 1459609664, 2, 1459600392, 2, 1459600456, 4, 1460186072, 84, 1460049056, 48, 1459080768, 0, 1459081896, 17, 1460208056, 11, 1460002968, 66, 1459100640, 0]
null
Status: 400
[]

Pankaj Jakhar

unread,
Apr 3, 2014, 7:24:27 AM4/3/14
to mobile-c...@googlegroups.com

After making a lot of research on this:

I found that you should not have any property in your map which has a key starting with underscore character '_' because it is reserved for CouchbaseLite.

CouchbaseLite currently does not give you a proper exception message for this so you will be stuck. The only thing you need to take care is to not to include any such key in your map.

Like if you have _id and _rev fields in your class(obj) then you need to remove them

map.remove("_id");
map.remove("_rev");

before calling:

try {
        document.putProperties(map);
    } catch (CouchbaseLiteException e) {
        e.printStackTrace();
    }

On Thursday, March 27, 2014 11:59:29 AM UTC+5:30, Pankaj Jakhar wrote:
Reply all
Reply to author
Forward
0 new messages